Skip to content

Commit

Permalink
Allow SIGINT set to be skipped via env variable.
Browse files Browse the repository at this point in the history
This is relevant when attempting to use Dask outside of pyGSTi,
where signals cannot be set in the workers.
Setting the PYGSTI_NO_CUSTOMLM_SIGINT env variable
now skips this behavior.
  • Loading branch information
sserita committed Sep 12, 2024
1 parent 911118c commit e670aeb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pygsti/optimize/customlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# http://www.apache.org/licenses/LICENSE-2.0 or in the LICENSE file in the root pyGSTi directory.
#***************************************************************************************************

import os as _os
import signal as _signal
import time as _time

Expand All @@ -25,7 +26,10 @@
# from scipy.optimize import OptimizeResult as _optResult

#Make sure SIGINT will generate a KeyboardInterrupt (even if we're launched in the background)
_signal.signal(_signal.SIGINT, _signal.default_int_handler)
#This may be problematic for multithreaded parallelism above pyGSTi, e.g. Dask,
#so this can be turned off by setting the PYGSTI_NO_CUSTOMLM_SIGINT environment variable
if 'PYGSTI_NO_CUSTOMLM_SIGINT' in _os.environ:
_signal.signal(_signal.SIGINT, _signal.default_int_handler)

#constants
_MACH_PRECISION = 1e-12
Expand Down

0 comments on commit e670aeb

Please sign in to comment.