Skip to content

Commit 2ee7397

Browse files
committed
Add support for using QEventLoop inside of QThread
1 parent a8e4873 commit 2ee7397

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

qasync/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def __exit__(self, *args):
234234

235235
def _format_handle(handle: asyncio.Handle):
236236
cb = getattr(handle, "_callback", None)
237-
if isinstance(getattr(cb, '__self__', None), asyncio.tasks.Task):
237+
if isinstance(getattr(cb, "__self__", None), asyncio.tasks.Task):
238238
return repr(cb.__self__)
239239
return str(handle)
240240

@@ -292,7 +292,11 @@ def timerEvent(self, event): # noqa: N802
292292
handle._run()
293293
dt = time.time() - t0
294294
if dt >= loop.slow_callback_duration:
295-
self._logger.warning('Executing %s took %.3f seconds', _format_handle(handle), dt)
295+
self._logger.warning(
296+
"Executing %s took %.3f seconds",
297+
_format_handle(handle),
298+
dt,
299+
)
296300
finally:
297301
loop._current_handle = None
298302
else:
@@ -420,7 +424,7 @@ def stop(*args):
420424
self.run_forever()
421425
finally:
422426
future.remove_done_callback(stop)
423-
self.__app.processEvents() # run loop one last time to process all the events
427+
self.__app.eventDispatcher().processEvents() # run loop one last time to process all the events
424428
if not future.done():
425429
raise RuntimeError("Event loop stopped before Future completed.")
426430

0 commit comments

Comments
 (0)