本文整理匯總了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''