@requires_good_network
def test_connection():
 global _server, _have_put_in_trigger
 trig_queue1 = queue.Queue()
 trig_queue2 = queue.Queue()
 thread1 = threading.Thread(target=_connect_client, args=(trig_queue1,))
 thread1.daemon = True
 thread2 = threading.Thread(target=_connect_client, args=(trig_queue2,))
 thread2.daemon = True
 thread1.start()
 thread2.start()
 with StimServer(port=4218, n_clients=2) as stim_server:
  _server = stim_server
  stim_server.start(timeout=10.0)
  stim_server.add_trigger(20)
  _have_put_in_trigger = True
  trig1 = trig_queue1.get(timeout=_max_wait)
  trig2 = trig_queue2.get(timeout=_max_wait)
  assert_equal(trig1, 20)
  assert_equal(trig1, trig2)
 with StimServer(port=4218) as stim_server:
  assert_raises(StopIteration, stim_server.start, 0.1)

@ requires_good_network def test_connection ( ) : global _server , _have_put_in_trigger trig_queue1 = queue . Queue ( ) trig_queue2 = queue . Queue ( ) thread1 = threading . Thread ( target = _connect_client , args = ( trig_queue1 , ) ) thread1 . daemon = True thread2 = threading . Thread ( target = _connect_client , args = ( trig_queue2 , ) ) thread2 . daemon = True thread1 . start ( ) thread2 . start ( ) with StimServer ( port = 4218 , n_clients = 2 ) as stim_server : _server = stim_server stim_server . start ( timeout = 10.0 ) stim_server . add_trigger ( 20 ) _have_put_in_trigger = True trig1 = trig_queue1 . get ( timeout = _max_wait ) trig2 = trig_queue2 . get ( timeout = _max_wait ) assert_equal ( trig1 , 20 ) assert_equal ( trig1 , trig2 ) with StimServer ( port = 4218 ) as stim_server : assert_raises ( StopIteration , stim_server . start , 0.1 )
test tcp/ip connection for stimserver <-> stimclient .