コード例 #1
0
def SocketClient(address):
    '''
    Return a connection object connected to the socket given by `address`
    '''
    family = MP.address_type(address)
    s = socket.socket(getattr(socket, family))
    defTimeOut = socket.getdefaulttimeout()
    s.settimeout(30)
    t = MP._init_timeout()

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

    fd = MP.duplicate(s.fileno())
    conn = MP._multiprocessing.Connection(fd)
    s.close()
    return conn
コード例 #2
0
ファイル: JediPatch.py プロジェクト: wguanicedew/panda-jedi
def SocketClient(address):
    '''
    Return a connection object connected to the socket given by `address`
    '''
    family = MP.address_type(address)
    s = socket.socket(getattr(socket, family))
    defTimeOut = socket.getdefaulttimeout()
    s.settimeout(30)
    t = MP._init_timeout()

    while 1:
        try:
            s.connect(address)
        except socket.error, e:
            if e.args[0] != errno.ECONNREFUSED or MP._check_timeout(t):
                MP.debug('failed to connect to address %s', address)
                raise
            time.sleep(0.01)
        else:
            break
コード例 #3
0
ファイル: JediPatch.py プロジェクト: PanDAWMS/panda-jedi
def SocketClient(address):
    '''
    Return a connection object connected to the socket given by `address`
    '''
    family = MP.address_type(address)
    s = socket.socket( getattr(socket, family) )
    defTimeOut = socket.getdefaulttimeout()
    s.settimeout(30)
    t = MP._init_timeout()

    while 1:
        try:
            s.connect(address)
        except socket.error, e:
            if e.args[0] != errno.ECONNREFUSED or MP._check_timeout(t):
                MP.debug('failed to connect to address %s', address)
                raise
            time.sleep(0.01)
        else:
            break
コード例 #4
0
ファイル: Listener.py プロジェクト: isabelmette/pynet
    def SocketClientv6(address, authkey):
        '''
        Return a connection object connected to the socket given by `address`
        '''
        import _multiprocessing
        import errno
        import time
        from multiprocessing.connection import duplicate, _init_timeout
        from multiprocessing.connection import _check_timeout, debug
        s = socket.socket( socket.AF_INET6 )
        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