本文整理汇总了Python中_multiprocessing.Connection方法的典型用法代码示例。如果您正苦于以下问题:Python _multiprocessing.Connection方法的具体用法?Python _multiprocessing.Connection怎么用?Python _multiprocessing.Connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_multiprocessing
的用法示例。
在下文中一共展示了_multiprocessing.Connection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Pipe
# 需要导入模块: import _multiprocessing [as 别名]
# 或者: from _multiprocessing import Connection [as 别名]
def Pipe(duplex=True):
'''
Returns pair of connection objects at either end of a pipe
'''
if duplex:
s1, s2 = socket.socketpair()
s1.setblocking(True)
s2.setblocking(True)
c1 = _multiprocessing.Connection(os.dup(s1.fileno()))
c2 = _multiprocessing.Connection(os.dup(s2.fileno()))
s1.close()
s2.close()
else:
fd1, fd2 = os.pipe()
c1 = _multiprocessing.Connection(fd1, writable=False)
c2 = _multiprocessing.Connection(fd2, readable=False)
return c1, c2
示例2: __init__
# 需要导入模块: import _multiprocessing [as 别名]
# 或者: from _multiprocessing import Connection [as 别名]
def __init__(self, f, regions=False, kind=None, samtools_path="samtools"):
ext = None
self.samtools_path = samtools_path
self.spool = None # use this to catch alignment during reader scraping
self.type = 'sam'
try:
self._f_name = f.name
_, ext = os.path.splitext(f.name)
if f.name == '<stdin>': # stdin stream
self._sam_init(f)
elif (ext is not None and ext.lower()) == '.bam' or (kind is not None and kind.lower() == 'bam'):
self._bam_init(f, regions)
self.type = 'bam'
elif (ext is not None and ext.lower()) == '.sam' or (kind is not None and kind.lower() == 'sam'):
self._sam_init(f)
else:
self._sam_init(f)
if (regions and (ext is not None and ext.lower() != '.bam') and kind is None) or (regions and kind is not None and kind.lower() != 'bam'):
self.__exit__()
raise ValueError("Region support requires bam file.")
except AttributeError:
self._f_name = None
if isinstance(f, Connection):
self._pipe_init(f)
else:
self._sam_init(f)
示例3: rebuild_handle
# 需要导入模块: import _multiprocessing [as 别名]
# 或者: from _multiprocessing import Connection [as 别名]
def rebuild_handle(pickled_data):
address, handle, inherited = pickled_data
if inherited:
return handle
sub_debug('rebuilding handle %d', handle)
conn = Client(address, authkey=current_process().authkey)
conn.send((handle, os.getpid()))
new_handle = recv_handle(conn)
conn.close()
return new_handle
#
# Register `_multiprocessing.Connection` with `ForkingPickler`
#
示例4: rebuild_connection
# 需要导入模块: import _multiprocessing [as 别名]
# 或者: from _multiprocessing import Connection [as 别名]
def rebuild_connection(reduced_handle, readable, writable):
handle = rebuild_handle(reduced_handle)
return _multiprocessing.Connection(
handle, readable=readable, writable=writable
)
示例5: accept
# 需要导入模块: import _multiprocessing [as 别名]
# 或者: from _multiprocessing import Connection [as 别名]
def accept(self):
'''
Accept a connection on the bound socket or named pipe of `self`.
Returns a `Connection` object.
'''
c = self._listener.accept()
if self._authkey:
deliver_challenge(c, self._authkey)
answer_challenge(c, self._authkey)
return c
示例6: rebuild_connection
# 需要导入模块: import _multiprocessing [as 别名]
# 或者: from _multiprocessing import Connection [as 别名]
def rebuild_connection(df, readable, writable):
fd = df.detach()
return Connection(fd, readable, writable)