@@ -30,7 +30,7 @@ async def run(*args, **kwargs):
3030
3131
3232async 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 ()
3434 timeout = now + timeout
3535 while now < timeout :
3636 message = await pubsub .get_message (
@@ -39,7 +39,7 @@ async def wait_for_message(pubsub, timeout=0.2, ignore_subscribe_messages=False)
3939 if message is not None :
4040 return message
4141 await asyncio .sleep (0.01 )
42- now = asyncio .get_event_loop ().time ()
42+ now = asyncio .get_running_loop ().time ()
4343 return None
4444
4545
@@ -675,7 +675,7 @@ async def loop_step():
675675 await messages .put (message )
676676 break
677677
678- task = asyncio .get_event_loop ().create_task (loop ())
678+ task = asyncio .get_running_loop ().create_task (loop ())
679679 # get the initial connect message
680680 async with async_timeout .timeout (1 ):
681681 message = await messages .get ()
@@ -724,7 +724,7 @@ def callback(message):
724724 messages = asyncio .Queue ()
725725 p = pubsub
726726 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 ())
728728 await r .publish ("foo" , "bar" )
729729 message = await messages .get ()
730730 task .cancel ()
@@ -748,7 +748,7 @@ def exception_handler_callback(e, pubsub) -> None:
748748 p = pubsub
749749 await self ._subscribe (p , foo = lambda x : None )
750750 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 (
752752 p .run (exception_handler = exception_handler_callback )
753753 )
754754 e = await exceptions .get ()
@@ -765,7 +765,7 @@ def callback(message):
765765
766766 messages = asyncio .Queue ()
767767 p = pubsub
768- task = asyncio .get_event_loop ().create_task (p .run ())
768+ task = asyncio .get_running_loop ().create_task (p .run ())
769769 # wait until loop gets settled. Add a subscription
770770 await asyncio .sleep (0.1 )
771771 await p .subscribe (foo = callback )
0 commit comments