File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -775,14 +775,13 @@ def callback(message):
775
775
await p .subscribe (foo = callback )
776
776
# wait tof the subscribe to finish. Cannot use _subscribe() because
777
777
# p.run() is already accepting messages
778
- await asyncio .sleep (0.1 )
779
- await r .publish ("foo" , "bar" )
780
- message = None
781
- try :
782
- async with async_timeout .timeout (0.1 ):
783
- message = await messages .get ()
784
- except asyncio .TimeoutError :
785
- pass
778
+ while True :
779
+ n = await r .publish ("foo" , "bar" )
780
+ if n == 1 :
781
+ break
782
+ await asyncio .sleep (0.1 )
783
+ async with async_timeout .timeout (0.1 ):
784
+ message = await messages .get ()
786
785
task .cancel ()
787
786
# we expect a cancelled error, not the Runtime error
788
787
# ("did you forget to call subscribe()"")
You can’t perform that action at this time.
0 commit comments