Skip to content

Commit ceb83e5

Browse files
committed
Fix - subprocess was not ready for testing
1 parent ebfe6c6 commit ceb83e5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/benchmark/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ async def run_pool(cls, queue_in, queue_out, workers, function='lambda: __import
3131
dispatcher = DispatcherMain({"producers": {"brokers": {}}, "pool": {"max_workers": workers}})
3232
pool = dispatcher.pool
3333
await pool.start_working(dispatcher)
34+
queue_out.put('ready')
3435

3536
print('waiting for message to start test')
3637
loop = asyncio.get_event_loop()
@@ -85,6 +86,9 @@ def start_server(self, workers, **kwargs):
8586
@contextlib.contextmanager
8687
def with_server(self, *args, **kwargs):
8788
process = self.start_server(*args, **kwargs)
89+
msg = self.queue_out.get()
90+
if msg != 'ready':
91+
raise RuntimeError('never got ready message from subprocess')
8892
try:
8993
yield self
9094
finally:
@@ -128,6 +132,10 @@ async def run_pool(cls, queue_in, queue_out, workers):
128132
{"producers": {"brokers": {"pg_notify": {"conninfo": CONNECTION_STRING}, "channels": CHANNELS}}, "pool": {"max_workers": workers}}
129133
)
130134
await dispatcher.start_working()
135+
# Make sure the dispatcher is listening before starting the tests which will submit messages
136+
for producer in dispatcher.producers:
137+
await producer.events.ready_event.wait()
138+
queue_out.put('ready')
131139

132140
print('waiting for message to start test')
133141
loop = asyncio.get_event_loop()

0 commit comments

Comments
 (0)