Skip to content

asyncio.get_event_loop() could be safely dropped from plumpy #336

@khsrali

Description

@khsrali

In #334, we localized the use case of asyncio.get_event_loop() in one function get_or_create_event_loop . Now aiida-core also, only calls on this function and not the fromer.

Having that said, asyncio.get_event_loop() can already be entirely removed from get_or_create_event_loop.
The only use case that's addressing at the moment, is when an event loop is created and set but not yet running. So on the next call it can still return that. This use case seems to be rare or almost none in aiida-core.

There are two suggestion on how to drop it, safely:

  1. cache the freshly created event loop after setting, and always prioritize returning that one on the next calls (in case that loop is not yet running, but not closed!).
  2. drop the need of aiida-core to access such loop. Ideally aiida-core could call only once on asyncio.new_event_loop and pass that loop internally to whoever needs it: transport, engine.utils, etc.

Solution number 2 is cleaner, but it might not be easily doable because also plumpy should follow the same logic in that case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions