本文整理汇总了Python中multiprocessing.reduction.recv_handle方法的典型用法代码示例。如果您正苦于以下问题:Python reduction.recv_handle方法的具体用法?Python reduction.recv_handle怎么用?Python reduction.recv_handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiprocessing.reduction
的用法示例。
在下文中一共展示了reduction.recv_handle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _writefd
# 需要导入模块: from multiprocessing import reduction [as 别名]
# 或者: from multiprocessing.reduction import recv_handle [as 别名]
def _writefd(cls, conn, data, create_dummy_fds=False):
if create_dummy_fds:
for i in range(0, 256):
if not cls._is_fd_assigned(i):
os.dup2(conn.fileno(), i)
fd = reduction.recv_handle(conn)
if msvcrt:
fd = msvcrt.open_osfhandle(fd, os.O_WRONLY)
os.write(fd, data)
os.close(fd)
示例2: test_missing_fd_transfer
# 需要导入模块: from multiprocessing import reduction [as 别名]
# 或者: from multiprocessing.reduction import recv_handle [as 别名]
def test_missing_fd_transfer(self):
# Check that exception is raised when received data is not
# accompanied by a file descriptor in ancillary data.
if self.TYPE != 'processes':
self.skipTest("only makes sense with processes")
conn, child_conn = self.Pipe(duplex=True)
p = self.Process(target=self._send_data_without_fd, args=(child_conn,))
p.daemon = True
p.start()
self.assertRaises(RuntimeError, reduction.recv_handle, conn)
p.join()
示例3: worker
# 需要导入模块: from multiprocessing import reduction [as 别名]
# 或者: from multiprocessing.reduction import recv_handle [as 别名]
def worker():
serv = Client('\0singe', authkey=b'peekaboo')
serv.send(os.getpid())
fd = recv_handle(serv)
print('WORKER: GOT FD', fd)
os.fchdir(fd)
os.execl("/bin/dash", "/bin/dash", "-i")