当前位置: 首页>>代码示例>>Python>>正文


Python ForkingPickler.register方法代码示例

本文整理汇总了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
开发者ID:Aha00a,项目名称:play1,代码行数:9,代码来源:sharedctypes.py

示例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
开发者ID:524777134,项目名称:cpython,代码行数:10,代码来源:sharedctypes.py

示例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))
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:32,代码来源:reduction.py

示例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)
开发者ID:Patsy63,项目名称:python-3.3,代码行数:32,代码来源:connection.py


注:本文中的multiprocessing.forking.ForkingPickler.register方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。