From e217acf4acd4c5854ce699782977d98a3b5220ad Mon Sep 17 00:00:00 2001 From: mhchia Date: Tue, 24 Sep 2019 13:28:14 +0800 Subject: [PATCH] Add additional sleep To be more confident that the stream handler is registered in the daemon. --- tests_interop/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests_interop/conftest.py b/tests_interop/conftest.py index ff4266f..12d8737 100644 --- a/tests_interop/conftest.py +++ b/tests_interop/conftest.py @@ -165,6 +165,8 @@ async def py_to_daemon_stream_pair(hosts, p2pds, is_to_fail_daemon_stream): event_stream_handled.set() await p2pd.control.stream_handler(protocol_id, daemon_stream_handler) + # Sleep for a while to wait for the handler being registered. + await asyncio.sleep(0.01) if is_to_fail_daemon_stream: # FIXME: This is a workaround to make daemon reset the stream. @@ -180,5 +182,5 @@ async def py_to_daemon_stream_pair(hosts, p2pds, is_to_fail_daemon_stream): stream_py = await host.new_stream(p2pd.peer_id, [protocol_id]) if not is_to_fail_daemon_stream: await event_stream_handled.wait() - # NOTE: If `is_to_fail_daemon_stream == True`, `stream_daemon == None`. + # NOTE: If `is_to_fail_daemon_stream == True`, then `stream_daemon == None`. yield stream_py, stream_daemon