对于python:Windows相当于SIGALRM感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍wind和python,并为您提供关于asp.net-mvc–在MVCSignalR服务器和W
对于python:Windows相当于SIGALRM感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍wind和python,并为您提供关于asp.net-mvc – 在MVC SignalR服务器和Windows服务SIgnalR客户端之间的SignalR、cmd – Windows相当于“touch”(即node.js创建index.html的方法)、iis – Windows 7相当于“Add-WindowsFeature”、MSDN Webcast - Silverlight for Windows Phone 开发系列课程(1):Windows Phone平台概况的有用信息。
本文目录一览:- python:Windows相当于SIGALRM(wind和python)
- asp.net-mvc – 在MVC SignalR服务器和Windows服务SIgnalR客户端之间的SignalR
- cmd – Windows相当于“touch”(即node.js创建index.html的方法)
- iis – Windows 7相当于“Add-WindowsFeature”
- MSDN Webcast - Silverlight for Windows Phone 开发系列课程(1):Windows Phone平台概况
python:Windows相当于SIGALRM(wind和python)
我有这个装饰器:
def timed_out(timeout): def decorate(f): if not hasattr(signal, "SIGALRM"): return f def handler(signum, frame): raise TimedOutExc() @functools.wraps(f) def new_f(*args, **kwargs): old = signal.signal(signal.SIGALRM, handler) signal.alarm(timeout) try: result = f(*args, **kwargs) finally: signal.signal(signal.SIGALRM, old) signal.alarm(0) return result new_f.func_name = f.func_name return new_f return decorate
该代码仅能在linux上执行任何操作,就像在Windows上一样SIGALRM
。在Windows中也可以使用此代码的最简单方法是什么?
答案1
小编典典它不是很漂亮,但是我不得不以跨平台的方式做类似的事情,于是我想到了使用单独的线程。基于信号的系统无法在所有平台上可靠地工作。
此类的使用可以包装在装饰器中,也可以制成with
上下文处理程序。
YMMV。
#!/usr/bin/env python2.7import time, threadingclass Ticker(threading.Thread): """A very simple thread that merely blocks for :attr:`interval` and sets a :class:`threading.Event` when the :attr:`interval` has elapsed. It then waits for the caller to unset this event before looping again. Example use:: t = Ticker(1.0) # make a ticker t.start() # start the ticker in a new thread try: while t.evt.wait(): # hang out til the time has elapsed t.evt.clear() # tell the ticker to loop again print time.time(), "FIRING!" except: t.stop() # tell the thread to stop t.join() # wait til the thread actually dies """ # SIGALRM based timing proved to be unreliable on various python installs, # so we use a simple thread that blocks on sleep and sets a threading.Event # when the timer expires, it does this forever. def __init__(self, interval): super(Ticker, self).__init__() self.interval = interval self.evt = threading.Event() self.evt.clear() self.should_run = threading.Event() self.should_run.set() def stop(self): """Stop the this thread. You probably want to call :meth:`join` immediately afterwards """ self.should_run.clear() def consume(self): was_set = self.evt.is_set() if was_set: self.evt.clear() return was_set def run(self): """The internal main method of this thread. Block for :attr:`interval` seconds before setting :attr:`Ticker.evt` .. warning:: Do not call this directly! Instead call :meth:`start`. """ while self.should_run.is_set(): time.sleep(self.interval) self.evt.set()
asp.net-mvc – 在MVC SignalR服务器和Windows服务SIgnalR客户端之间的SignalR
指定URL的服务器代码
app.MapSignalR("/signalr",new HubConfiguration());
如果我这样做,邮件将在哪里?当您做新的HubConfiguration时,集线器是什么?
它说我可以连接
NET client code that specifies the URL var hubConnection = new HubConnection("http://contoso.com/signalr",useDefaultUrl: false);
我会在我的Windows Server中,但是如果我在服务器上发送文本到http://myserver.com/signalr,我该如何得到它?什么中心?
还有哪里最好把它放在Windows服务中?一个很棒的例子
解决方法
在客户端(Windows服务)上:
protected override async void OnStart(string[] args) { eventLog1.WriteEntry("In OnStart"); try { var hubConnection = new HubConnection("http://www.savitassa.com/signalr",useDefaultUrl: false); IHubProxy alphaProxy = hubConnection.CreateHubProxy("AlphaHub"); await hubConnection.Start(); await alphaProxy.Invoke("Hello","Message from Service"); } catch (Exception ex) { eventLog1.WriteEntry(ex.Message); } }
在服务器上:
public class AlphaHub : Hub { public void Hello(string message) { // We got the string from the Windows Service // using SignalR. Now need to send to the clients Clients.All.addNewMessagetoPage(message); // Send message to Windows Service }
cmd – Windows相当于“touch”(即node.js创建index.html的方法)
'touch' is not recognized as an internal or external command,operable program or batch file.
当我按照instructions做:
touch index.html app.js style.css
是否有相当于使用“触摸”的窗口?我需要手动创建这些文件(并修改它们以更改时间戳),以实现这种命令?这似乎不是… node-ish …
type nul > your_file.txt
这将创建0个字节的your_file.txt文件。
使用echo命令的另一种方法是
echo.>your_file.txt
回声。 – 将在其中创建一个空行的文件。
iis – Windows 7相当于“Add-WindowsFeature”
它不一定是脚本. Windows功能只是开发人员负责个人修改的几种配置之一.确保(例如)在给定开发人员的计算机上正确配置IIS和某些服务也是很好的.如果有一个更大规模的工具可以给我们这个功能,我也会对此感兴趣.我只是对disM犹豫不决,因为我不知道它,它似乎改变了图像文件.
dism / Online / Get-Features
启用功能:
dism / Online / Enable-Feature / FeatureName:featureA
禁用功能:
dism / Online / disable-Feature / FeatureName:featureB
使用dism作为管理员访问appwiz.cpl的风险不大/风险小.
重新编辑
这是我在发布之前已经尝试过的脚本.它将迭代可用的功能并列出其功能名称和显示名称 – 这是appwiz.cpl中显示的内容.我仍然相信有人会发布一个优雅的单行,这让人感到羞耻:
@ECHO OFF FOR /F "usebackq tokens=3,*" %%a in (`dism /Online /Get-Features ^| find /i "name"`) do ( dism /Online /Get-FeatureInfo /FeatureName:"%%b" | find /i "name" )
MSDN Webcast - Silverlight for Windows Phone 开发系列课程(1):Windows Phone平台概况
技术等级:Level 100
通过真实设备的演示Windows Phone的新功能特点。
然后讲述Windows Phone的硬件规范,软件架构和开发平台。
最后讲述适合学习和开发Windows Phone应用的群体,以及给各种开发者的建议。
视频下载: http://download.microsoft.com/download/2/4/5/245F4ABD-385D-45D3-9EE3-6CD3Ebed8005/WebCast20101113_Video.zip PDF下载: http://download.microsoft.com/download/2/4/5/245F4ABD-385D-45D3-9EE3-6CD3Ebed8005/WebCast20101113_PDF.zip |
我们今天的关于python:Windows相当于SIGALRM和wind和python的分享已经告一段落,感谢您的关注,如果您想了解更多关于asp.net-mvc – 在MVC SignalR服务器和Windows服务SIgnalR客户端之间的SignalR、cmd – Windows相当于“touch”(即node.js创建index.html的方法)、iis – Windows 7相当于“Add-WindowsFeature”、MSDN Webcast - Silverlight for Windows Phone 开发系列课程(1):Windows Phone平台概况的相关信息,请在本站查询。
本文标签: