Adapt to plumpy's greenlet async bridge#7188
Closed
khsrali wants to merge 11 commits into
Closed
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7188 +/- ##
==========================================
- Coverage 79.66% 79.48% -0.17%
==========================================
Files 565 565
Lines 43637 43769 +132
==========================================
+ Hits 34759 34786 +27
- Misses 8878 8983 +105 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Collaborator
Author
|
src/aiida/transports/transport.py:180: in __enter__
self.open()
src/aiida/transports/transport.py:1838: in open
return self.run_command_blocking(self.open_async)
src/aiida/transports/transport.py:1835: in run_command_blocking
return loop.run_until_complete(func(*args, **kwargs))
src/aiida/engine/runners.py:160: in run_until_complete
return self._loop.run_until_complete(future)
EDIT: |
Collaborator
Author
|
Ok, it works now! 🎊 |
This was referenced Feb 3, 2026
Collaborator
Author
|
closed in favour of #7206 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This accompanies the plumpy PR that replaces nest_asyncio with greenlet-based bridging.
AiiDA has several places where synchronous code needs to call async operations while the event loop is running — process execution, the kill path, and async transport operations. Each needs adapting to work within the greenlet model.
Additionally, dropping
nest_asynciobreaks Jupyter notebooks --there's absolutely no way not to break it!--:The kernel has a running event loop, there's no greenlet context.
The only backward incompatible change, In notebooks, users write:
Since Jupyter supports top-level
await, this works naturally. The async path callsrun_in_greenletinternally, so all the nested execution machinery works correctly. That means no need forasyncio.run(), etc from the user side.We solve this by providing an async API in line with sync ones. I believe this is a more decent solution over the patching or working around the event loop, as it was before.
Anyways, in scripts (where the loop is NOT running), the synchronous API still works as before: