本文整理汇总了Python中asyncore.file_dispatcher方法的典型用法代码示例。如果您正苦于以下问题:Python asyncore.file_dispatcher方法的具体用法?Python asyncore.file_dispatcher怎么用?Python asyncore.file_dispatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asyncore
的用法示例。
在下文中一共展示了asyncore.file_dispatcher方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_dispatcher [as 别名]
def __init__(self, map):
_triggerbase.__init__(self)
r, self.trigger = self._fds = os.pipe()
asyncore.file_dispatcher.__init__(self, r, map=map)
示例2: test_dispatcher
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_dispatcher [as 别名]
def test_dispatcher(self):
fd = os.open(TESTFN, os.O_RDONLY)
data = []
class FileDispatcher(asyncore.file_dispatcher):
def handle_read(self):
data.append(self.recv(29))
s = FileDispatcher(fd)
os.close(fd)
asyncore.loop(timeout=0.01, use_poll=True, count=2)
self.assertEqual(b"".join(data), self.d)
示例3: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_dispatcher [as 别名]
def __init__(self, watch_manager, default_proc_fun=None, read_freq=0,
threshold=0, timeout=None, channel_map=None):
"""
Initializes the async notifier. The only additional parameter is
'channel_map' which is the optional asyncore private map. See
Notifier class for the meaning of the others parameters.
"""
Notifier.__init__(self, watch_manager, default_proc_fun, read_freq,
threshold, timeout)
asyncore.file_dispatcher.__init__(self, self._fd, channel_map)
示例4: test_dispatcher
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_dispatcher [as 别名]
def test_dispatcher(self):
fd = os.open(support.TESTFN, os.O_RDONLY)
data = []
class FileDispatcher(asyncore.file_dispatcher):
def handle_read(self):
data.append(self.recv(29))
s = FileDispatcher(fd)
os.close(fd)
asyncore.loop(timeout=0.01, use_poll=True, count=2)
self.assertEqual(b"".join(data), self.d)
示例5: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_dispatcher [as 别名]
def __init__(self, cid=None):
if _debug: ConsoleClient._debug("__init__ cid=%r", cid)
asyncore.file_dispatcher.__init__(self, sys.stdin)
Client.__init__(self, cid)
示例6: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_dispatcher [as 别名]
def __init__(self):
if _debug: WaitableEvent._debug("__init__")
# make a pipe
self._read_fd, self._write_fd = os.pipe()
# continue with init
asyncore.file_dispatcher.__init__(self, self._read_fd)
示例7: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_dispatcher [as 别名]
def __init__(self, fd: int) -> None:
asyncore.file_dispatcher.__init__(self, fd)
self.fd = fd
self.read_buffer = b''
self.write_buffer = b''