python的SIGIO handler,sigiohandler,On Linux, us
python的SIGIO handler,sigiohandler,On Linux, us
On Linux, use this to manage objects that can cause a SIGIO to be generated.It calls all registered objects.
# this handler manages a chain of registered callback functions. class SIGIOHandler: def __init__(self): self.handlers = [] self.on() def on(self): signal.signal(signal.SIGIO, self) def off(self): signal.signal(signal.SIGIO, signal.SIG_DFL) def register(self, callback): self.handlers.append(callback) return len(self.handlers) - 1 # the handle def unregister(self, handle=0): if self.handlers: del self.handlers[handle] def __call__(self, sig, frame): for h in self.handlers: h(frame)# a singleton instance of the SIGIOHandler. Usually, users of this module only# have to register a DirectoryNotifier object here. Other objects (Dispatcher# objects) are registered with the poller (which is already set up to be called# when SIGIO occurs). But you may add your own hooks to it.try: managerexcept NameError: manager = SIGIOHandler()
Use this to register callable objects that need to handle SIGIO events. Thisallows asyncronous operation of various file, socket, and directory events.
Only works with Linux.
相关内容
- python写的一个骰子程序,python写骰子程序,import rando
- python中RGB和HSL的相互转换,pythonrgbhsl,def HSL_to_R
- Python从int继承实现枚举,pythonint枚举,枚举可以给数字一
- python使用urllib2模拟http post,pythonurllib2,使用urllib2.ur
- python在windows下执行子进程时隐藏命令行窗口,python窗口
- python正则表达式判断文本中是否有中文,python正则表达
- python分割文件,,#!/usr/bin/e
- python with语句使用示例,pythonwith,下面代码中的Entry类
- python动态修改类方法的执行逻辑,python动态逻辑,下面的
- 获取文件夹大小的python代码,获取python代码,import osfr
评论关闭