Skip to content

fix: dynamically select timeout method to avoid PicklingError on macOS (#185)#186

Merged
seanthegeek merged 2 commits intodomainaware:masterfrom
ultradns:master
Oct 1, 2025
Merged

fix: dynamically select timeout method to avoid PicklingError on macOS (#185)#186
seanthegeek merged 2 commits intodomainaware:masterfrom
ultradns:master

Conversation

@sbarbett
Copy link
Copy Markdown
Contributor

@sbarbett sbarbett commented Sep 22, 2025

This PR fixes a platform-specific issue on macOS where check_domains() fails with a PicklingError due to Python’s multiprocessing defaulting to the spawn start method. The decorated test_starttls function cannot be pickled, which causes the subprocess to fail.

See issue #185 for the problem report and stack trace.

Changes:

  • Introduces a private helper function _get_timeout_method() that:

    • Uses signals on macOS (avoids multiprocessing entirely).
    • Uses multiprocessing on Windows (signals are not available).
    • Uses signals on Linux/Unix by default, unless multiple threads are detected (to avoid signal conflicts).
  • Applies this selection dynamically to timeout_decorator.timeout(..., use_signals=...) in test_starttls.

Rationale:

Using signal-based timeouts on macOS avoids the need to pickle the decorated function, preventing PicklingError. This approach is cross-platform, does not change behavior for Linux, and gracefully handles multithreaded environments.

Testing:

  • Verified on:

    • macOS Sonoma 14.x + Python 3.13.2 (Homebrew) — check_domains() now runs without raising PicklingError.
    • Linux (x86_64 + aarch64) — no regressions observed.

Related Issue

Closes #185.

@sbarbett sbarbett changed the title Title: fix: dynamically select timeout method to avoid PicklingError on macOS (#185) fix: dynamically select timeout method to avoid PicklingError on macOS (#185) Sep 22, 2025
@steinbrueckri
Copy link
Copy Markdown

@sbarbett THX for your fix! ❤️

@seanthegeek seanthegeek merged commit 7a858cd into domainaware:master Oct 1, 2025
1 check failed
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.

PicklingError on macOS when running check_domains due to multiprocessing spawn

3 participants