本文整理汇总了Python中multiprocessing.forking.ForkingPickler.register方法的典型用法代码示例。如果您正苦于以下问题:Python ForkingPickler.register方法的具体用法?Python ForkingPickler.register怎么用?Python ForkingPickler.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiprocessing.forking.ForkingPickler
的用法示例。
在下文中一共展示了ForkingPickler.register方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rebuild_ctype
# 需要导入模块: from multiprocessing.forking import ForkingPickler [as 别名]
# 或者: from multiprocessing.forking.ForkingPickler import register [as 别名]
def rebuild_ctype(type_, wrapper, length):
if length is not None:
type_ = type_ * length
ForkingPickler.register(type_, reduce_ctype)
obj = type_.from_address(wrapper.get_address())
obj._wrapper = wrapper
return obj
示例2: rebuild_ctype
# 需要导入模块: from multiprocessing.forking import ForkingPickler [as 别名]
# 或者: from multiprocessing.forking.ForkingPickler import register [as 别名]
def rebuild_ctype(type_, wrapper, length):
if length is not None:
type_ = type_ * length
ForkingPickler.register(type_, reduce_ctype)
buf = wrapper.create_memoryview()
obj = type_.from_buffer(buf)
obj._wrapper = wrapper
return obj
示例3: recv_handle
# 需要导入模块: from multiprocessing.forking import ForkingPickler [as 别名]
# 或者: from multiprocessing.forking.ForkingPickler import register [as 别名]
new_handle = recv_handle(conn)
conn.close()
return new_handle
def reduce_connection(conn):
rh = reduce_handle(conn.fileno())
return (rebuild_connection, (rh, conn.readable, conn.writable))
def rebuild_connection(reduced_handle, readable, writable):
handle = rebuild_handle(reduced_handle)
return _multiprocessing.Connection(handle, readable=readable, writable=writable)
ForkingPickler.register(_multiprocessing.Connection, reduce_connection)
def fromfd(fd, family, type_, proto = 0):
s = socket.fromfd(fd, family, type_, proto)
if s.__class__ is not socket.socket:
s = socket.socket(_sock=s)
return s
def reduce_socket(s):
reduced_handle = reduce_handle(s.fileno())
return (rebuild_socket, (reduced_handle,
s.family,
s.type,
s.proto))
示例4:
# 需要导入模块: from multiprocessing.forking import ForkingPickler [as 别名]
# 或者: from multiprocessing.forking.ForkingPickler import register [as 别名]
if timeout <= 0:
return select.select(object_list, [], [], 0)[0]
else:
deadline = time.time() + timeout
while True:
try:
return select.select(object_list, [], [], timeout)[0]
except OSError as e:
if e.errno != errno.EINTR:
raise
if timeout is not None:
timeout = deadline - time.time()
#
# Make connection and socket objects sharable if possible
#
if sys.platform == 'win32':
from . import reduction
ForkingPickler.register(socket.socket, reduction.reduce_socket)
ForkingPickler.register(Connection, reduction.reduce_connection)
ForkingPickler.register(PipeConnection, reduction.reduce_pipe_connection)
else:
try:
from . import reduction
except ImportError:
pass
else:
ForkingPickler.register(socket.socket, reduction.reduce_socket)
ForkingPickler.register(Connection, reduction.reduce_connection)