• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python forking.duplicate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中multiprocessing.forking.duplicate函数的典型用法代码示例。如果您正苦于以下问题:Python duplicate函数的具体用法?Python duplicate怎么用?Python duplicate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了duplicate函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: send_handle

 def send_handle(conn, handle, destination_pid):
     process_handle = win32.OpenProcess(win32.PROCESS_ALL_ACCESS, False, destination_pid)
     try:
         new_handle = duplicate(handle, process_handle)
         conn.send(new_handle)
     finally:
         close(process_handle)
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:7,代码来源:reduction.py


示例2: SocketClient

def SocketClient(address):
    '''
    Return a connection object connected to the socket given by `address`
    '''
    family = address_type(address)
    with socket.socket( getattr(socket, family) ) as s:
        s.setblocking(True)
        t = _init_timeout()

        while 1:
            try:
                s.connect(address)
            except socket.error as e:
                if e.args[0] != errno.ECONNREFUSED or _check_timeout(t):
                    debug('failed to connect to address %s', address)
                    raise
                time.sleep(0.01)
            else:
                break
        else:
            raise

        fd = duplicate(s.fileno())
    conn = _multiprocessing.Connection(fd)
    return conn
开发者ID:7modelsan,项目名称:kbengine,代码行数:25,代码来源:connection.py


示例3: reduce_handle

def reduce_handle(handle):
    if Popen.thread_is_spawning():
        return (None, Popen.duplicate_for_child(handle), True)
    dup_handle = duplicate(handle)
    _cache.add(dup_handle)
    sub_debug('reducing handle %d', handle)
    return (_get_listener().address, dup_handle, False)
开发者ID:Arrjaan,项目名称:Cliff,代码行数:7,代码来源:reduction.py


示例4: accept

 def accept(self):
     s, self._last_accepted = self._socket.accept()
     s.setblocking(True)
     fd = duplicate(s.fileno())
     conn = _multiprocessing.Connection(fd)
     s.close()
     return conn
开发者ID:7modelsan,项目名称:kbengine,代码行数:7,代码来源:connection.py


示例5: accept

 def accept(self):
     s, self._last_accepted = self._socket.accept()
     # non-blocking sockets fix for issue 6056
     s.settimeout(None)
     fd = duplicate(s.fileno())
     conn = _multiprocessing.Connection(fd)
     s.close()
     return conn
开发者ID:jjdmol,项目名称:LOFAR,代码行数:8,代码来源:connection.py


示例6: accept

 def accept(self):
     while True:
         try:
             s, self._last_accepted = self._socket.accept()
         except socket.error as e:
             if e.args[0] != errno.EINTR:
                 raise
         else:
             break
     s.setblocking(True)
     fd = duplicate(s.fileno())
     conn = _multiprocessing.Connection(fd)
     s.close()
     return conn
开发者ID:openebs,项目名称:vsm-image,代码行数:14,代码来源:connection.py


示例7: other_process_run

def other_process_run():
    sock_other = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    sock_other.bind(server_address)
    sock_other.listen(1)
    c, address = sock_other.accept()
    print "address=" + address
    fd = duplicate(c.fileno())
    c.close()
    conn = Connection(fd)
    try:
        print conn.recv_bytes(10)
    finally:
        conn.close()
    print "other process exit"
开发者ID:liujingchen,项目名称:fixgevent,代码行数:14,代码来源:test_socket.py


示例8: __init__

      def __init__(self, process_obj, env):
        # No super init call by intention!

        from multiprocessing.forking import duplicate, get_command_line, _python_exe, close, get_preparation_data, HIGHEST_PROTOCOL, dump
        import msvcrt
        import _subprocess

        # create pipe for communication with child
        rfd, wfd = os.pipe()

        # get handle for read end of the pipe and make it inheritable
        rhandle = duplicate(msvcrt.get_osfhandle(rfd), inheritable=True)
        os.close(rfd)

        # start process
        cmd = get_command_line() + [rhandle]
        cmd = ' '.join('"%s"' % x for x in cmd)
        hp, ht, pid, tid = _subprocess.CreateProcess(
          _python_exe, cmd, None, None, 1, 0, env, None, None
        )
        ht.Close()
        close(rhandle)

        # set attributes of self
        self.pid = pid
        self.returncode = None
        self._handle = hp

        # send information to child
        prep_data = get_preparation_data(process_obj._name)
        to_child = os.fdopen(wfd, 'wb')
        mp_Popen._tls.process_handle = int(hp)
        try:
          dump(prep_data, to_child, HIGHEST_PROTOCOL)
          dump(process_obj, to_child, HIGHEST_PROTOCOL)
        finally:
          del mp_Popen._tls.process_handle
          to_child.close()
开发者ID:atuxhe,项目名称:returnn,代码行数:38,代码来源:TaskSystem.py


示例9: SocketClient

def SocketClient(address):
    '''
    Return a connection object connected to the socket given by `address`
    '''
    family = address_type(address)
    s = socket.socket( getattr(socket, family) )

    while 1:
        try:
            s.connect(address)
        except socket.error as e:
            if e.args[0] != errno.ECONNREFUSED: # connection refused
                debug('failed to connect to address %s', address)
                raise
            time.sleep(0.01)
        else:
            break
    else:
        raise

    fd = duplicate(s.fileno())
    conn = _multiprocessing.Connection(fd)
    s.close()
    return conn
开发者ID:LinkedModernismProject,项目名称:web_code,代码行数:24,代码来源:connection.py


示例10: _init_timeout

    t = _init_timeout()

    while 1:
        try:
            s.connect(address)
        except socket.error, e:
            if e.args[0] != errno.ECONNREFUSED or _check_timeout(t):
                debug('failed to connect to address %s', address)
                raise
            time.sleep(0.01)
        else:
            break
    else:
        raise

    fd = duplicate(s.fileno())
    conn = _multiprocessing.Connection(fd)
    s.close()
    return conn

#
# Definitions for connections based on named pipes
#

if sys.platform == 'win32':

    class PipeListener(object):
        '''
        Representation of a named pipe
        '''
        def __init__(self, address, backlog=None):
开发者ID:1018365842,项目名称:FreeIMU,代码行数:31,代码来源:connection.py


示例11: copy_socket

 def copy_socket(fd):
     rhandle = duplicate(fd, inheritable=True)
     return rhandle
开发者ID:lambacck,项目名称:Spawning,代码行数:3,代码来源:spawning_controller.py


示例12: copy_fd

 def copy_fd(fd):
     rhandle = duplicate(msvcrt.get_osfhandle(fd), inheritable=True)
     os.close(fd)
     return rhandle
开发者ID:lambacck,项目名称:Spawning,代码行数:4,代码来源:spawning_controller.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python forking.ForkingPickler类代码示例发布时间:2022-05-27
下一篇:
Python forking.close函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap