Skip to content

Close nautilus internal pools to silence shutdown AttributeError#1223

Merged
Jammy2211 merged 1 commit intomainfrom
feature/nautilus-pool-teardown
Apr 18, 2026
Merged

Close nautilus internal pools to silence shutdown AttributeError#1223
Jammy2211 merged 1 commit intomainfrom
feature/nautilus-pool-teardown

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

Nautilus's fit_multiprocessing passes pool=N to nautilus.Sampler(...), which then creates two multiprocessing.Pool objects (pool_l, pool_s) internally. PyAutoFit never closed them, so their finalizers fired at Python interpreter shutdown — after pickle had already been torn down — producing:

Exception ignored in: <function Pool.__del__ at 0x...>
  File ".../multiprocessing/pool.py", line 271, in __del__
  File ".../multiprocessing/queues.py", line 393, in put
AttributeError: 'NoneType' object has no attribute 'dumps'

The fit itself is correct, but the stderr noise makes smoke-test output look like a failure and trips log-scraping heuristics. This PR closes + joins the two pools after call_search returns.

API Changes

None — internal cleanup only.
See full details below.

Test Plan

  • pytest test_autofit/non_linear/ — 239 passed
  • python scripts/searches/nest/Nautilus.py in autofit_workspace under smoke-test env vars — completes with exit 0 and no Exception ignored / Pool.__del__ / AttributeError in the log
  • Full autofit_workspace smoke suite (7 scripts) re-run — all clean
Full API Changes (for automation & release notes)

Removed

  • None

Added

  • None

Changed Behaviour

  • autofit.non_linear.search.nest.nautilus.Nautilus.fit_multiprocessing — now closes and joins search_internal.pool_l and search_internal.pool_s before returning, and nulls those attributes. Observable effect: the teardown AttributeError at interpreter shutdown is gone. No change to the returned search_internal semantics (the pools were never reused after this point).

Migration

  • None required.

🤖 Generated with Claude Code

Nautilus creates its own multiprocessing.Pool instances (pool_l, pool_s)
internally when pool=N. Previously these were never closed, so their
finalizers fired at interpreter shutdown — after the pickle module had
been torn down — producing a cosmetic but noisy:

    Exception ignored in: <function Pool.__del__ at 0x...>
    AttributeError: 'NoneType' object has no attribute 'dumps'

Close and join the pools once call_search has returned (after the last
iteration, where output_search_internal would otherwise need them alive).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release Pending next release build label Apr 18, 2026
@Jammy2211 Jammy2211 merged commit 9dbc55c into main Apr 18, 2026
2 checks passed
@Jammy2211 Jammy2211 deleted the feature/nautilus-pool-teardown branch April 18, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release Pending next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant