-
Notifications
You must be signed in to change notification settings - Fork 50
[PERF]: execute XPIA injection handle activation concurrently #165
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
base: main
Are you sure you want to change the base?
Changes from all commits
620b49c
d8e7dfa
03d68da
74473b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,10 +163,22 @@ async def _activate_handles_async( | |
| Args: | ||
| stack (AsyncExitStack): The exit stack managing cleanup. | ||
| """ | ||
| for handle in self._handles: | ||
| await stack.enter_async_context(handle) | ||
|
|
||
| # Concurrent: total = max of all wait times | ||
| async def _enter_handle(h: InjectionHandle) -> None: | ||
| await stack.enter_async_context(h) | ||
|
|
||
| # Concurrent context entry (network uploads) | ||
| try: | ||
| async with asyncio.TaskGroup() as tg: | ||
| for handle in self._handles: | ||
| tg.create_task(_enter_handle(handle)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please replace results = await asyncio.gather(
*(stack.enter_async_context(handle) for handle in self._handles),
return_exceptions=True,
)
errors = [result for result in results if isinstance(result, BaseException)]
if errors:
raise errors[0]
# Keep the existing readiness TaskGroup here.This preserves concurrent activation while allowing successful siblings to register cleanup. Please also add unit tests: a regression test where one handle fails immediately and another finishes activation after a delay would cover the partial-failure case. |
||
| except ExceptionGroup as eg: | ||
| # Unwrap the first exception for cleaner error reporting. | ||
| # BaseExecution already catches and reports exceptions, | ||
| # but ExceptionGroup obscures the underlying InfrastructureError. | ||
| raise eg.exceptions[0] from eg | ||
|
apocalypse9949 marked this conversation as resolved.
|
||
|
|
||
| # Concurrent readiness wait (indexing delays) | ||
| async with asyncio.TaskGroup() as tg: | ||
| for handle in self._handles: | ||
| tg.create_task(handle.wait_until_ready()) | ||
|
|
||
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.
Linter flagged: async function
_enter_handlemust be named with an_asyncsuffix (e.g._enter_handle_async) to pass through CI