def connect(cls, host, port, socket_class=PolledSocket, state_callback=None): """ Create an FCPClient which owns a new FCPConnection. NOTE: If you need multiple FCPClient instances it is better to explictly create an FCPConnection and use the FCPClient.__init__() method so that all instances are multiplexed over the same connection. """ sock = None conn = None raised = True try: sock = socket_class(host, port) conn = FCPConnection(sock, True, state_callback) raised = False finally: if raised: if conn: conn.close() if sock: sock.close() return FCPClient(conn)
def connect(cls, host, port, socket_class = PolledSocket, state_callback = None): """ Create an FCPClient which owns a new FCPConnection. NOTE: If you need multiple FCPClient instances it is better to explictly create an FCPConnection and use the FCPClient.__init__() method so that all instances are multiplexed over the same connection. """ sock = None conn = None raised = True try: sock = socket_class(host, port) conn = FCPConnection(sock, True, state_callback) raised = False finally: if raised: if conn: conn.close() if sock: sock.close() return FCPClient(conn)