Skip to content

Commit

Permalink
TST: improve execution time for 0MQ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgav committed Apr 20, 2024
1 parent d6ca5be commit 951f0d9
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/bluesky/tests/test_zmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@ def test_proxy_script():
def test_zmq_basic(RE, hw):
# COMPONENT 1
# Run a 0MQ proxy on a separate process.
def start_proxy():

def start_proxy(start_event):
start_event.set()
Proxy(5567, 5568).start()

proxy_proc = multiprocess.Process(target=start_proxy, daemon=True)
proxy_start_event = multiprocess.Event()
proxy_proc = multiprocess.Process(target=start_proxy, args=(proxy_start_event,), daemon=True)
proxy_proc.start()
time.sleep(5) # Give this plenty of time to start up.
proxy_start_event.wait(timeout=5)
assert proxy_start_event.is_set()
time.sleep(0.2)

##time.sleep(5) # Give this plenty of time to start up.

# COMPONENT 2
# Run a Publisher and a RunEngine in this main process.
Expand All @@ -41,21 +48,29 @@ def start_proxy():
# it receives over a Queue to this process, so we can count them for our
# test.

def make_and_start_dispatcher(queue):
def make_and_start_dispatcher(queue, start_event):
def put_in_queue(name, doc):
print("putting ", name, "in queue")
start_event.set()
queue.put((name, doc))

d = RemoteDispatcher("127.0.0.1:5568")
d.subscribe(put_in_queue)
print("REMOTE IS READY TO START")
d.loop.call_later(9, d.stop)
start_event.set()
d.start()


dispatcher_start_event = multiprocess.Event()
queue = multiprocess.Queue()
dispatcher_proc = multiprocess.Process(target=make_and_start_dispatcher, daemon=True, args=(queue,))
dispatcher_proc = multiprocess.Process(target=make_and_start_dispatcher, daemon=True, args=(queue, dispatcher_start_event))
dispatcher_proc.start()
time.sleep(5) # As above, give this plenty of time to start.
dispatcher_start_event.wait(timeout=5)
assert dispatcher_start_event.is_set()
time.sleep(0.2)

#time.sleep(5) # As above, give this plenty of time to start.

# Generate two documents. The Publisher will send them to the proxy
# device over 5567, and the proxy will send them to the
Expand Down

0 comments on commit 951f0d9

Please sign in to comment.