@@ -30,7 +30,7 @@ async def run(*args, **kwargs):
30
30
31
31
32
32
async def wait_for_message (pubsub , timeout = 0.2 , ignore_subscribe_messages = False ):
33
- now = asyncio .get_event_loop ().time ()
33
+ now = asyncio .get_running_loop ().time ()
34
34
timeout = now + timeout
35
35
while now < timeout :
36
36
message = await pubsub .get_message (
@@ -39,7 +39,7 @@ async def wait_for_message(pubsub, timeout=0.2, ignore_subscribe_messages=False)
39
39
if message is not None :
40
40
return message
41
41
await asyncio .sleep (0.01 )
42
- now = asyncio .get_event_loop ().time ()
42
+ now = asyncio .get_running_loop ().time ()
43
43
return None
44
44
45
45
@@ -675,7 +675,7 @@ async def loop_step():
675
675
await messages .put (message )
676
676
break
677
677
678
- task = asyncio .get_event_loop ().create_task (loop ())
678
+ task = asyncio .get_running_loop ().create_task (loop ())
679
679
# get the initial connect message
680
680
async with async_timeout .timeout (1 ):
681
681
message = await messages .get ()
@@ -724,7 +724,7 @@ def callback(message):
724
724
messages = asyncio .Queue ()
725
725
p = pubsub
726
726
await self ._subscribe (p , foo = callback )
727
- task = asyncio .get_event_loop ().create_task (p .run ())
727
+ task = asyncio .get_running_loop ().create_task (p .run ())
728
728
await r .publish ("foo" , "bar" )
729
729
message = await messages .get ()
730
730
task .cancel ()
@@ -748,7 +748,7 @@ def exception_handler_callback(e, pubsub) -> None:
748
748
p = pubsub
749
749
await self ._subscribe (p , foo = lambda x : None )
750
750
with mock .patch .object (p , "get_message" , side_effect = Exception ("error" )):
751
- task = asyncio .get_event_loop ().create_task (
751
+ task = asyncio .get_running_loop ().create_task (
752
752
p .run (exception_handler = exception_handler_callback )
753
753
)
754
754
e = await exceptions .get ()
@@ -765,7 +765,7 @@ def callback(message):
765
765
766
766
messages = asyncio .Queue ()
767
767
p = pubsub
768
- task = asyncio .get_event_loop ().create_task (p .run ())
768
+ task = asyncio .get_running_loop ().create_task (p .run ())
769
769
# wait until loop gets settled. Add a subscription
770
770
await asyncio .sleep (0.1 )
771
771
await p .subscribe (foo = callback )
0 commit comments