Skip to content

Commit

Permalink
Undo removal of SIGINT handler before launching mp Pool
Browse files Browse the repository at this point in the history
Removing and adding back the signal handler causes an error when
running with multiprocessing from Matlab, and doesn't provide much
improvement in usability
  • Loading branch information
rebeccafair committed Nov 5, 2019
1 parent 8432bca commit 2bb8d7f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
7 changes: 0 additions & 7 deletions euphonic/data/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,9 @@ def calculate_fine_phonons(
# Try to create a multiprocessing pool first, in case it fails
if nprocs > 1:
try:
import signal
from multiprocessing import Pool
from functools import partial
# Temporarily remove SIGINT handler before creating pool, so
# child processes don't inherit it. Instead handle SIGINT
# (e.g. keyboard interrupts) from the main process only and
# terminate the pool before exiting
sigint_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
pool = Pool(processes=nprocs)
signal.signal(signal.SIGINT, sigint_handler)
except RuntimeError:
warnings.warn(('\nA RuntimeError was raised when initialising '
'the multiprocessing Pool. This is probably due'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setup(
name='euphonic',
version='0.1dev2',
version='0.1dev3',
author='Rebecca Fair',
author_email='rebecca.fair@stfc.ac.uk',
description=(
Expand Down

0 comments on commit 2bb8d7f

Please sign in to comment.