Skip to content

Async event loop halts execution when not running async functions #5021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ygorpontelo opened this issue Jan 15, 2024 · 1 comment
Closed

Comments

@ygorpontelo
Copy link
Contributor

The current implementation for integrating async functions use loop.run_until_complete. This function runs the event loop until the result from the coroutine is done and then halts the execution of the event loop. This causes any scheduled coroutines to to also halt execution. This is not too bad because every time you run another coroutine, the execution resumes, but this is not ideal.

The idea is to maintain current behaviour when executing async functions, but when the coroutine finishes, the loop somehow continues to execute in the background. This way, the coroutines scheduled are not blocked by the main thread.

I have an implementation that i think could solve this issue. It starts a thread that runs the event loop in the background when robot is executing normal keywords. If the keyword is async, this threads stops and robot runs as usual, once the result is done we start another thread and repeat the process.

Unfortunally, this is still not truly parallel execution because threads in python have the GIL and event loops cannot be serialized for us to use multiprocessing, i tried but didn't succeed. Nevertheless any IO bound code will not halt the execution of the event loop anymore, this includes functions like sleep not blocking coroutines.

@ygorpontelo
Copy link
Contributor Author

See #5022 for more info.

@ygorpontelo ygorpontelo closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant