Skip to content

Commit

Permalink
Merge pull request #592 from jkloetzke/catch-wsl1
Browse files Browse the repository at this point in the history
Handle WSL1 `forkserver` problems
  • Loading branch information
jkloetzke authored Oct 14, 2024
2 parents 1aae83d + 126e11d commit 0f55e6f
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions pym/bob/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,15 +708,23 @@ def getProcessPoolExecutor():
# To "prime" the process pool a dummy workload must be executed because
# the processes are spawned lazily.
origSigInt = signal.getsignal(signal.SIGINT)
signal.signal(signal.SIGINT, signal.SIG_IGN)

method = 'fork' if isWindows() else 'forkserver'
__setStartMethod(method)
executor = concurrent.futures.ProcessPoolExecutor()

# fork early before process gets big
executor.submit(dummy).result()
signal.signal(signal.SIGINT, origSigInt)
try:
signal.signal(signal.SIGINT, signal.SIG_IGN)

method = 'fork' if isWindows() else 'forkserver'
__setStartMethod(method)
executor = concurrent.futures.ProcessPoolExecutor()

# fork early before process gets big
executor.submit(dummy).result()
finally:
signal.signal(signal.SIGINT, origSigInt)
except EOFError:
# On Windows WSL1, the 'forkserver' method does not work because UNIX
# domain sockets are not fully implemented. Fall back to the 'spawn'
# method. See bug #562.
multiprocessing.set_start_method('spawn', force=True)
executor = concurrent.futures.ProcessPoolExecutor()
except OSError as e:
raise BuildError("Error spawning process pool: " + str(e))

Expand Down

0 comments on commit 0f55e6f

Please sign in to comment.