Skip to content
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

Bug Fix: Plugins Fail To Load on Python 3.8+ #505

Merged
merged 2 commits into from
Feb 2, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion detect_secrets/core/secrets_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def scan_files(self, *filenames: str, num_processors: Optional[int] = None) -> N
if not num_processors:
num_processors = mp.cpu_count()

with mp.Pool(processes=num_processors) as p:
# Default to fork multiprocessing. Python 3.8+ defaults to spawn which doesn't share memory.
with mp.get_context('fork').Pool(processes=num_processors) as p:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did find on https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods

that it says fork should not be used on macOS, and that it's not available on Windows

so it may be better to resolve this some other way

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to pass the settings object to the child processes.

for secrets in p.imap_unordered(
_scan_file_and_serialize,
[os.path.join(self.root, filename) for filename in filenames],
Expand Down