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


Python connection.Listener方法代码示例

本文整理汇总了Python中multiprocessing.connection.Listener方法的典型用法代码示例。如果您正苦于以下问题:Python connection.Listener方法的具体用法?Python connection.Listener怎么用?Python connection.Listener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在multiprocessing.connection的用法示例。


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

示例1: main

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def main():
    global arpListener, config

    parser = argparse.ArgumentParser()
    parser.add_argument('dir', help='the directory of the example')
    args = parser.parse_args()

    # locate config file
    config_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),"..","examples",args.dir,"config","sdx_global.cfg")

    logger.info("Reading config file %s", config_file)
    config = parse_config(config_file)

    logger.info("Starting ARP Listener")
    arpListener = ArpListener()
    ap_thread = Thread(target=arpListener.start)
    ap_thread.start()

    # start pctrl listener in foreground
    logger.info("Starting PCTRL Listener")
    pctrlListener = PctrlListener()
    pctrlListener.start() 
开发者ID:sdn-ixp,项目名称:iSDX,代码行数:24,代码来源:arproxy.py

示例2: test_issue14725

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def test_issue14725(self):
        l = self.connection.Listener()
        p = self.Process(target=self._test, args=(l.address,))
        p.daemon = True
        p.start()
        time.sleep(1)
        # On Windows the client process should by now have connected,
        # written data and closed the pipe handle by now.  This causes
        # ConnectNamdedPipe() to fail with ERROR_NO_DATA.  See Issue
        # 14725.
        conn = l.accept()
        self.assertEqual(conn.recv(), 'hello')
        conn.close()
        p.join()
        l.close()

#
# Test of sending connection and socket objects between processes
# 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:test_multiprocessing.py

示例3: test_timeout

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def test_timeout(self):
        old_timeout = socket.getdefaulttimeout()
        try:
            socket.setdefaulttimeout(0.1)
            parent, child = multiprocessing.Pipe(duplex=True)
            l = multiprocessing.connection.Listener(family='AF_INET')
            p = multiprocessing.Process(target=self._test_timeout,
                                        args=(child, l.address))
            p.start()
            child.close()
            self.assertEqual(parent.recv(), 123)
            parent.close()
            conn = l.accept()
            self.assertEqual(conn.recv(), 456)
            conn.close()
            l.close()
            p.join(10)
        finally:
            socket.setdefaulttimeout(old_timeout)

#
# Test what happens with no "if __name__ == '__main__'"
# 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_multiprocessing.py

示例4: _get_listener

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def _get_listener():
    global _listener

    if _listener is None:
        _lock.acquire()
        try:
            if _listener is None:
                debug('starting listener and thread for sending handles')
                _listener = Listener(authkey=current_process().authkey)
                t = threading.Thread(target=_serve)
                t.daemon = True
                t.start()
        finally:
            _lock.release()

    return _listener 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:18,代码来源:reduction.py

示例5: _listener

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def _listener(cls, conn, families):
        for fam in families:
            l = cls.connection.Listener(family=fam)
            conn.send(l.address)
            new_conn = l.accept()
            conn.send(new_conn)
            new_conn.close()
            l.close()

        l = socket.socket()
        l.bind((test.support.HOST, 0))
        l.listen()
        conn.send(l.getsockname())
        new_conn, addr = l.accept()
        conn.send(new_conn)
        new_conn.close()
        l.close()

        conn.recv() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:_test_multiprocessing.py

示例6: __init__

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def __init__(self, server=None, authkey='klustakwik',
                 global_ns=None, local_ns=None, level=0):
        if multiprocessing is None:
            raise ImportError('Cannot import the required multiprocessing module.')
        if server is None:
            server = ('localhost', 2719)
        frame = inspect.stack()[level + 1][0]
        ns_global, ns_local = frame.f_globals, frame.f_locals
        if global_ns is None:
            global_ns = frame.f_globals
        if local_ns is None:
            local_ns = frame.f_locals
        self.local_ns = local_ns
        self.global_ns = global_ns
        self.listener = Listener(server, authkey=authkey)
        self.conn = None 
开发者ID:kwikteam,项目名称:klustakwik2,代码行数:18,代码来源:monitoring.py

示例7: _listener

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def _listener(cls, conn, families):
        for fam in families:
            l = cls.connection.Listener(family=fam)
            conn.send(l.address)
            new_conn = l.accept()
            conn.send(new_conn)
            new_conn.close()
            l.close()

        l = socket.socket()
        l.bind((test.support.HOST, 0))
        l.listen(1)
        conn.send(l.getsockname())
        new_conn, addr = l.accept()
        conn.send(new_conn)
        new_conn.close()
        l.close()

        conn.recv() 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:21,代码来源:_test_multiprocessing.py

示例8: attach_debugger

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def attach_debugger(host='localhost', port=6000, authkey='secret password'):
    import gluon.contrib.qdb as qdb
    import gluon.debug
    from multiprocessing.connection import Listener

    if isinstance(authkey, unicode):
        authkey = authkey.encode('utf8')

    if not hasattr(gluon.debug, 'qdb_listener'):
        # create a remote debugger server and wait for connection
        address = (host, port)     # family is deduced to be 'AF_INET'
        gluon.debug.qdb_listener = Listener(address, authkey=authkey)
        gluon.debug.qdb_connection = gluon.debug.qdb_listener.accept()
        # create the backend
        gluon.debug.qdb_debugger = qdb.Qdb(gluon.debug.qdb_connection)
        gluon.debug.dbg = gluon.debug.qdb_debugger
        # welcome message (this should be displayed on the frontend)
        print 'debugger connected to', gluon.debug.qdb_listener.last_accepted
    return True     # connection successful! 
开发者ID:uwdata,项目名称:termite-data-server,代码行数:21,代码来源:webservices.py

示例9: __init__

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def __init__(self, logger):
        self.logger = logger

        self.listener = Listener(('localhost', 6000), authkey='xrs', backlog=100)

        self.sender_queue = Queue()
        self.receiver_queue = Queue() 
开发者ID:sdn-ixp,项目名称:iSDX,代码行数:9,代码来源:server.py

示例10: __init__

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def __init__(self):
        logger.info("Initializing the BGP PctrlListener")
        self.listener = Listener(config.ah_socket, authkey=None, backlog=100)
        self.run = True 
开发者ID:sdn-ixp,项目名称:iSDX,代码行数:6,代码来源:route_server.py

示例11: __init__

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def __init__(self):
        # "Set listener for ARP replies from the participants' controller"
        logger.info("Starting the PctrlListener")
        self.listener_garp = Listener(config.garp_socket, authkey=None, backlog=100) 
开发者ID:sdn-ixp,项目名称:iSDX,代码行数:6,代码来源:arproxy.py

示例12: __init__

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def __init__(self, address, port, logger):
        self.logger = logger
        self.listener = Listener((address, port), backlog=100) 
开发者ID:sdn-ixp,项目名称:iSDX,代码行数:5,代码来源:participant_server.py

示例13: test_rapid_restart

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def test_rapid_restart(self):
        authkey = os.urandom(32)
        manager = QueueManager(
            address=(test.support.HOST, 0), authkey=authkey, serializer=SERIALIZER)
        srvr = manager.get_server()
        addr = srvr.address
        # Close the connection.Listener socket which gets opened as a part
        # of manager.get_server(). It's not needed for the test.
        srvr.listener.close()
        manager.start()

        p = self.Process(target=self._putter, args=(manager.address, authkey))
        p.start()
        p.join()
        queue = manager.get_queue()
        self.assertEqual(queue.get(), 'hello world')
        del queue
        manager.shutdown()

        manager = QueueManager(
            address=addr, authkey=authkey, serializer=SERIALIZER)
        manager.start()
        manager.shutdown()

#
#
# 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:29,代码来源:test_multiprocessing.py

示例14: test_listener_client

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def test_listener_client(self):
        for family in self.connection.families:
            l = self.connection.Listener(family=family)
            p = self.Process(target=self._test, args=(l.address,))
            p.daemon = True
            p.start()
            conn = l.accept()
            self.assertEqual(conn.recv(), 'hello')
            p.join()
            l.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_multiprocessing.py

示例15: _test_ignore_listener

# 需要导入模块: from multiprocessing import connection [as 别名]
# 或者: from multiprocessing.connection import Listener [as 别名]
def _test_ignore_listener(cls, conn):
        def handler(signum, frame):
            pass
        signal.signal(signal.SIGUSR1, handler)
        l = multiprocessing.connection.Listener()
        conn.send(l.address)
        a = l.accept()
        a.send('welcome') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_multiprocessing.py


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