Skip to content

Retire the previous background worker pool when resetting the executor #404

Open

Description

@Apeksha9389

Resetting Cachier's background executor replaces its reference without calling shutdown() on the previous ThreadPoolExecutor. An application that updates the worker setting can leave old idle workers alive and old pools still accepting submissions until garbage collection cleans them up.

Reproduced on master e5fd990, Python 3.12.14, memory backend / core worker utility:

from cachier.core import _get_executor
old = _get_executor()
old.submit(str, 'start a worker').result()
_get_executor(reset=True)
old.submit(str, 'still accepts work').result()  # unexpectedly succeeds

The previous executor should stop accepting new submissions while its running and queued calculations finish. Reset should not wait for long-running cache calculations. A regression test reproduces the missing retirement; a proposed fix also preserves the original pool if constructing its replacement fails. This isolates item 15 in #367.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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