File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -813,9 +813,12 @@ def wrapper(*args, **kwargs):
813813 return outer_decorator
814814
815815@contextlib .contextmanager
816- def _use_qeventloop ():
816+ def _use_qeventloop (loop_factory ):
817817 app = QApplication .instance () or QApplication ([sys .argv ])
818- loop = QEventLoop (app )
818+ if loop_factory is None :
819+ loop = QEventLoop (app )
820+ else :
821+ loop = loop_factory (app )
819822 old_loop = asyncio .get_event_loop ()
820823 asyncio .set_event_loop (loop )
821824 try :
@@ -824,11 +827,12 @@ def _use_qeventloop():
824827 loop .close ()
825828 asyncio .set_event_loop (old_loop )
826829
827-
828- def run (future ):
830+ # A run function matching the signature of asyncio.run
831+ def run (main_coro , * , debug = None , loop_factory = None ):
829832 """
830833 Run the given coroutine using a QEventLoop.
831834 """
832- with _use_qeventloop () as loop :
833- return loop .run_until_complete (future )
834-
835+ with _use_qeventloop (loop_factory ) as loop :
836+ if debug is not None :
837+ loop .set_debug (debug )
838+ return loop .run_until_complete (main_coro )
You can’t perform that action at this time.
0 commit comments