def test_4_1(n_topics=10): if 1: ws = WebSocketClient(ROSBRIDGE_HOST) else: ws = RosBridgeClient(ROSBRIDGE_HOST) ws.connect() topicArrived = threading.Event() for i_top in xrange(n_topics): topicArrived.clear() def genf(i_topic=0): return lambda data: topicArrived.set() subID = ws.subscribe(SUBTOPIC, MSGTYPE, genf(i_top)) got_msg = topicArrived.wait(2.0) ws.unsubscribe(subID) ws.close()