File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -824,7 +824,10 @@ def _use_qeventloop(loop_factory):
824824 loop = QEventLoop (app )
825825 else :
826826 loop = loop_factory (app )
827- old_loop = asyncio .get_event_loop ()
827+ try :
828+ old_loop = asyncio .get_event_loop ()
829+ except RuntimeError : # No current event loop
830+ old_loop = None
828831 asyncio .set_event_loop (loop )
829832 try :
830833 yield loop
Original file line number Diff line number Diff line change 11import qasync
22import asyncio
3+ from qasync import QApplication
34
45def test_run_with_contextmanager (application ):
56 async def coro ():
67 event_loop = asyncio .get_event_loop ()
78 assert type (event_loop ).__name__ == "QSelectorEventLoop"
89 await asyncio .sleep (0 )
910
10- _ = application
1111 qasync .run (coro ())
1212
13- event_loop = asyncio .get_event_loop ()
13+ try :
14+ event_loop = asyncio .get_event_loop ()
15+ except :
16+ event_loop = None
1417 assert type (event_loop ).__name__ != "QSelectorEventLoop"
You can’t perform that action at this time.
0 commit comments