Skip to content

Instantly share code, notes, and snippets.

@0x0L
Created September 28, 2021 15:17
Show Gist options
  • Save 0x0L/763cc4def938eda66668ff8f6d48a0a9 to your computer and use it in GitHub Desktop.
Save 0x0L/763cc4def938eda66668ff8f6d48a0a9 to your computer and use it in GitHub Desktop.
import os
from multiprocessing import get_context
from concurrent.futures import ProcessPoolExecutor
from concurrent.futures.thread import _global_shutdown_lock as L
os.register_at_fork(
before=L.acquire,
after_in_child=L._at_fork_reinit,
after_in_parent=L.release
)
with ProcessPoolExecutor(mp_context=get_context('fork')) as pool:
r = list(pool.map(str, range(100)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment