qasync icon indicating copy to clipboard operation
qasync copied to clipboard

Monitoring blocking time within event loop with `set_debug()` doesn't work

Open temeddix opened this issue 1 year ago • 0 comments

When using asyncio, we can find the blocking code like this:

import asyncio
import time


async def main():
    time.sleep(1)  # Block event loop

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.set_debug(True)  # Enable debug
    loop.slow_callback_duration = 0.1
    loop.run_until_complete(main())
Executing <Task finished coro=<main() [...]> took 1.016 seconds
  • https://stackoverflow.com/questions/38856410/monitoring-the-asyncio-event-loop

However, when using qasync, no output is printed even if there's blocking inside the event loop. I'm using macOS on Apple Silicon.

from qasync import QEventLoop
import time


async def main():
    time.sleep(1)  # Block event loop

if __name__ == "__main__":
    ...
    loop = QEventLoop(app)
    loop.set_debug(True)  # Enable debug
    loop.slow_callback_duration = 0.1
    loop.run_until_complete(main())

temeddix avatar Nov 14 '23 09:11 temeddix