Skip to content

Refactor pool lifecycle: ctx-based termination and GracefulShutdown#1

Merged
alesr merged 4 commits into
mainfrom
ctx-termination-graceful-shutdown
May 12, 2026
Merged

Refactor pool lifecycle: ctx-based termination and GracefulShutdown#1
alesr merged 4 commits into
mainfrom
ctx-termination-graceful-shutdown

Conversation

@alesr

@alesr alesr commented May 12, 2026

Copy link
Copy Markdown
Owner

This PR introduce a pool context which can be used to terminate the pool without waiting for queued tasks to complete (ungraceful path), in addition to the existing Shutdown method now renamed to GracefulShutdown which drains the tasks in the buffer.

Also, replace time.Sleep by synctest and improve test coverage and readability.

alesr added 4 commits May 12, 2026 19:35
Pool initialization now accepts a ctx for immediate termination:
workers exit without draining buffered tasks, though any in-flight
task runs to completion.

The existing Shutdown method is renamed to GracefulShutdown, which
drains all buffered tasks and waits for workers to finish. It returns
an error if the ctx was cancelled before shutdown completed.
Also use sync test to avoid waiting
@codecov

codecov Bot commented May 12, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@alesr alesr merged commit 99d863e into main May 12, 2026
4 of 6 checks passed
@alesr alesr deleted the ctx-termination-graceful-shutdown branch May 12, 2026 18:54
@alesr alesr self-assigned this May 12, 2026
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

Successfully merging this pull request may close these issues.

1 participant