Created
September 28, 2021 15:17
-
-
Save 0x0L/763cc4def938eda66668ff8f6d48a0a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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