-
Notifications
You must be signed in to change notification settings - Fork 53
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
fileinstall: run coros in the background if loop already running #2744
Conversation
7136d7c
to
698f234
Compare
698f234
to
191ce20
Compare
191ce20
to
8398cfe
Compare
# set containing references to "background" coroutines that are not referenced | ||
# from any code (i.e. are not directly awaited), adding them to this list | ||
# avoids the potential for garbage collection to delete them whilst they are | ||
# running | ||
_BACKGROUND_TASKS = set() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures that background tasks are always referenced whilst they are running.
That is so long as the module doesn't get housekept 🙈
For details: https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task
MyPy Failure is the same as on master! |
* Allow Rose file installation to be called by code which already has an event loop running by scheduling coroutines to run in the background (i.e. schedule but don't await). * The calling code can list these tasks using `asyncio.all_tasks()` and await them as appropriate. * Addresses cylc/cylc-rose#274
8398cfe
to
be7004c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Read changes
- Run tests locally
- Tried to break various components of this
One out of the triplet of PRs which closes cylc/cylc-rose#274
asyncio.all_tasks()
and await them as appropriate.For testing instructions see the cylc-flow PR.