Created
September 20, 2022 16:07
-
-
Save mturoci/0a51202946f20fa18ccf99da9c7ad283 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Do not run like this - will block the whole thread - freeze the app. | |
# blocking_function(q, loop) | |
# Get the current event loop - will be used for | |
# running async functions within the blocking. | |
loop = asyncio.get_event_loop() | |
# Create an event to use for cancellation. | |
q.client.event = Event() | |
with concurrent.futures.ThreadPoolExecutor() as pool: | |
await q.exec(pool, blocking_function, q, loop) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment