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


Python Waldo.tcp_connect方法代码示例

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


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

示例1: run_test

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def run_test():
    '''
    Tests Waldo's capability of propagating an exception back through nested
    sequences. Here we have two pairs of endpoints: (a,b), (c,d). Endpoint a 
    begins a sequence with b, which makes and endpoint call to c, which 
    initiates a sequence with d, which raises an exception.

    Returns true if the exception is propagated back to the root of the
    event and handled and false otherwise.
    '''
    Waldo.tcp_accept(InnerPong, HOST, PORT_INNER, throw_func)
    inner_ping = Waldo.tcp_connect(InnerPing, HOST, PORT_INNER)
    Waldo.tcp_accept(OuterPong, HOST, PORT_OUTER, inner_ping)
    outer_ping = Waldo.tcp_connect(OuterPing, HOST, PORT_OUTER)
    return outer_ping.testNestedSequencePropagation()
开发者ID:bmistree,项目名称:Waldo,代码行数:17,代码来源:application_exception_nested_sequence_test.py

示例2: main

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def main():
        #Connecting + Starting
        client = Waldo.tcp_connect(Client, HOSTNAME, PORT)
        print 'Started'
        startTime = time.time()


        #Sending all messages
        try:
                for n in range(0, numMessages):
                        client.send_msg()
        except:
                print 'Sending message failed.'


        #Packaging time and sending it
        totalTime = time.time() - startTime
        print "Finished: " + str(totalTime)
        numClients = 1
        if(len(sys.argv) >= 2):
                #assume numClients is only one unless the number of clients is given
                numClients = int(sys.argv[1])


        #Writing and closing
        client.stop()
        f = open('clientLog', 'a')
        f.write(str(numClients) + ' ' + str(numClients * numMessages) + ' ' + str(totalTime) + '\n')
        f.close()
开发者ID:harrison8989,项目名称:Waldo,代码行数:31,代码来源:client.py

示例3: main

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def main():
    # Connecting + Starting
    client = Waldo.tcp_connect(Client, HOSTNAME, PORT)
    print "Started"
    startTime = time.time()

    # Sending all messages
    try:
        for n in range(0, 100):
            client.send_msg(str(100))
            time.sleep(DELAY)
        for n in range(100, numMessages):
            client.send_msg(str(n))
            time.sleep(DELAY)
    except:
        print "Sending message failed."

    # Packaging time and sending it
    totalTime = time.time() - startTime
    print "Finished: " + str(totalTime)
    numClients = 1
    if len(sys.argv) >= 2:
        # assume numClients is only one unless the number of clients is given
        numClients = int(sys.argv[1])

    # Writing and closing
    client.stop()
    f = open("clientLog", "a")
    f.write(str(numClients) + " " + str(numClients * numMessages) + " " + str(totalTime) + "\n")
    f.close()
开发者ID:harrison8989,项目名称:Waldo,代码行数:32,代码来源:client.py

示例4: run_test

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def run_test():
    accept_stoppable = Waldo.tcp_accept(
        SideA, SIDEA_HOST, SIDEA_PORT,
        connected_callback=sidea_connected)
    
    sideb = Waldo.tcp_connect(
        SideB,SIDEA_HOST,SIDEA_PORT)

    sidea = sidea_wait_queue.get()

    sidea.add_stop_listener(sidea_stop_listener)
    sideb.add_stop_listener(sideb_stop_listener_1)
    sideb.add_stop_listener(sideb_stop_listener_2)
    listener_id = sideb.add_stop_listener(sideb_stop_listener_2)
    sideb.remove_stop_listener(listener_id)
    sideb.remove_stop_listener(listener_id)
    
    sidea.do_nothing()
    sideb.do_nothing()
    sidea.stop()
    time.sleep(1)

    if sidea_stop_counter != 1:
        return False
    
    if sideb_stop_counter != 3:
        return False

    return True
开发者ID:bmistree,项目名称:Waldo,代码行数:31,代码来源:two_side_stop_callbacks.py

示例5: run_test

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def run_test():
    accept_stoppable = Waldo.tcp_accept(
        SideA, SIDEA_HOST, SIDEA_PORT,
        connected_callback=sidea_connected)
    
    sideb = Waldo.tcp_connect(
        SideB,SIDEA_HOST,SIDEA_PORT)

    sidea = sidea_wait_queue.get()

    sidea.do_nothing()
    sideb.do_nothing()

    sidea.stop()
    time.sleep(1)

    # ensure that stop fires on single host.
    try:
        sidea.do_nothing()
        return False
    except Waldo.StoppedException as inst:
        pass

    # ensure that the other side also sees the stop.
    try:
        sideb.do_nothing()
        return False
    except Waldo.StoppedException as inst:
        pass

    return True
开发者ID:harrison8989,项目名称:Waldo,代码行数:33,代码来源:two_side_stop.py

示例6: add_single_dht_node

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def add_single_dht_node(node_host_port_pair):

    # first: connect to discovery service
    requester = Waldo.tcp_connect(
        Requester,
        conf.COORDINATOR_HOST_PORT_PAIR.host,
        conf.COORDINATOR_HOST_PORT_PAIR.port,
        # the host and port that our new dht node will listen on for
        # connections to other dht nodes.
        node_host_port_pair.host,
        node_host_port_pair.port)

    # request request addresses of other nodes to contact from
    # discovery service, plus register self with discovery service.
    uuid, finger_table, next, prev = requester.register()
    dht_node = Waldo.no_partner_create(
        Node,uuid,util_funcs.distance,util_funcs.hashed_uuid,
        util_funcs.between, util_funcs.debug_print)
    
    # listen for connections to my node
    def on_connected(sidea_endpoint):
        sidea_endpoint.add_connection_to_node()

    Waldo.tcp_accept(
        NodeSideA, node_host_port_pair.host,
        node_host_port_pair.port, dht_node,
        node_host_port_pair.host,
        node_host_port_pair.port,
        connected_callback = on_connected)
    
    # connect to other nodes in my finger table
    for uuid in finger_table.keys():
        # table_entry has form:
        #   host: <text>
        #   port: <number>
        #   valid: <bool>
        #   uuid: <text>
        table_entry = finger_table[uuid]
        host_to_connect_to = table_entry['host']
        port_to_connect_to = table_entry['port']
        
        connection_to_finger_table_node = Waldo.tcp_connect(
            NodeSideB, host_to_connect_to, port_to_connect_to,
            dht_node,node_host_port_pair.host, node_host_port_pair.port)
    
    return dht_node
开发者ID:bmistree,项目名称:Waldo,代码行数:48,代码来源:dht_lib.py

示例7: run_test

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def run_test():
    '''
    Tests Waldo's ability to detect an application exception on the partner
    endpoint mid-sequence and propagate that exception back to the root endpoint
    for handling.
    
    Returns true if the exception is caught and handled, and false otherwise.
    '''
    Waldo.tcp_accept(Pong,HOST,PORT)
    connector = Waldo.tcp_connect(Ping,HOST,PORT)
    return connector.testPropagateException()
开发者ID:bmistree,项目名称:Waldo,代码行数:13,代码来源:application_exception_sequence_propagate_test.py

示例8: run_test

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def run_test():
    '''
    Tests Waldo's ability to propagate an ApplicationException back through an
    endpoint call on the remote partner in a sequence. The exception should be
    passed back to the root endpoint which initiates the sequence.
    
    Returns true if the exception is caught and handled, and false otherwise.
    '''
    thrower = Waldo.no_partner_create(Pong,None)
    catcher_partner = Waldo.tcp_accept(Pong,HOST,PORT,thrower)
    catcher = Waldo.tcp_connect(Ping,HOST,PORT)
    return catcher.testExceptionPropagation()
开发者ID:bmistree,项目名称:Waldo,代码行数:14,代码来源:application_exception_sequence_with_endpoint_call_test.py

示例9: run_test

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def run_test():
    Waldo.tcp_accept(Pt2, HOST, PORT, connected_callback=pt2_connected)
    pt1 = Waldo.tcp_connect(Pt1, HOST, PORT,createList);

    pt2 = pt2_wait_queue.get()
    returned_list = pt1.start_seq()
    time.sleep(1)
    list_to_return.append('wo')
    if returned_list != list_to_return:
        return False

    return True
开发者ID:bmistree,项目名称:Waldo,代码行数:14,代码来源:foreign_func_in_sequence.py

示例10: run_test

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def run_test():
    '''
    Tests Waldo's ability to propagate an exception back through a sequence within
    an endpoint call.
    
    Returns true if the exception is caught and handled, and false otherwise.
    '''
    Waldo.tcp_accept(Pong,HOST,PORT)
    connector = Waldo.tcp_connect(Ping,HOST,PORT)
    catcher = Waldo.no_partner_create(Catcher)
    catcher.addEndpoint(connector)
    return catcher.testCatchApplicationExceptionFromSequence()
开发者ID:bmistree,项目名称:Waldo,代码行数:14,代码来源:application_exception_endpoint_call_with_sequence_test.py

示例11: ask

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def ask():
    """
  Asks the listening endpoint for a list of its users, parses it,
  and prints a unique list of users logged on at the other 
  endpoint. 
  """
    sender = Waldo.tcp_connect(EndpointA, HOSTNAME, PORT)
    print "Users on", HOSTNAME
    users = sender.ask_for_list()
    user_list = users.strip("\n").split(" ")
    user_list = list(set(user_list))
    for user in user_list:
        print "\t", user
开发者ID:JayThomason,项目名称:waldo-tests,代码行数:15,代码来源:who.py

示例12: run_test

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def run_test():
    '''
    Tests Waldo's capability of propagating a network exception back through
    a sequence. Here we have two pairs of endpoints: (a,b), (c,d). Endpoint a 
    begins a sequence with b, which makes and endpoint call to c, which 
    initiates a sequence with d. Endpoint d is in a separate process which is
    manually terminated mid-sequence, thus a network exception should be
    detected by c and propagated back to a.

    Returns true if the exception is propagated back to the root of the
    event and handled and false otherwise.
    '''
    global acceptor_proc
    Waldo.set_default_heartbeat_period(1)
    Waldo.set_default_partner_timeout(2)
    acceptor_proc.start()
    time.sleep(SLEEP_TIME) # make sure process is ready for tcp_connect
    inner_ping = Waldo.tcp_connect(InnerPing, HOST, PORT_INNER)
    Waldo.tcp_accept(OuterPong, HOST, PORT_OUTER, inner_ping)
    outer_ping = Waldo.tcp_connect(OuterPing, HOST, PORT_OUTER)
    result = outer_ping.testNestedSequencePropagation()
    acceptor_proc.terminate()
    return result
开发者ID:bmistree,项目名称:Waldo,代码行数:25,代码来源:network_exception_nested_sequence_test.py

示例13: run_test

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def run_test():
    '''
    Tests Waldo's ability to detect a network failure between two endpoints
    mid-sequence, thrown a NetworkException, and catch that exception using
    a try-catch.
    
    Returns true if the exception is caught and handled, and false otherwise.
    '''
    Waldo.set_default_heartbeat_period(1)
    Waldo.set_default_partner_timeout(3)
    acceptor_process.start()
    time.sleep(SLEEP_TIME)
    connector = Waldo.tcp_connect(Ping,HOST,PORT,signal_func)
    return connector.testNetworkException()
开发者ID:bmistree,项目名称:Waldo,代码行数:16,代码来源:network_exception_mid_sequence_test.py

示例14: run_test

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def run_test():
    '''
    Tests that Waldo can detect a network exception mid-sequence and propagate
    that exception back through an endpoint call.

    Returns true if the test passes and false otherwise.
    '''
    Waldo.set_default_heartbeat_period(1)
    Waldo.set_default_partner_timeout(2)
    acceptor_process.start()
    time.sleep(SLEEP_TIME)
    endpt = Waldo.tcp_connect(Ping, HOST, PORT)
    endpt.addTerminationFunction(signal_func)
    catcher = Waldo.no_partner_create(Catcher)
    catcher.addEndpoint(endpt)
    return catcher.testPropagateNetworkExceptionOnEndpointCall()
开发者ID:bmistree,项目名称:Waldo,代码行数:18,代码来源:network_exception_test_propagate_endpoint_call.py

示例15: getMSG

# 需要导入模块: from waldo.lib import Waldo [as 别名]
# 或者: from waldo.lib.Waldo import tcp_connect [as 别名]
def getMSG(endpoint, msg):
        global startTime
        global c
        global numClients
        global hit
        if msg == '0':
                hit = False
                print 'start'
                startTime = time.time()
        if msg == '999' and not hit:
                f.write(str(numClients) + ' ' + str(numClients * numMessages) + ' ' + str(time.time() - startTime) + '\n')
                print time.time() - startTime
                print 'finished'
                numClients += 1
                client = Waldo.tcp_connect(Client, HOSTNAME, PORT, getMSG)
                c.append(client)
                hit = True
开发者ID:harrison8989,项目名称:Waldo,代码行数:19,代码来源:client.py


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