Skip to content
Snippets Groups Projects
Commit 0a3d5568 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

workaround for issue 1255 in PyPy

see https://bugs.pypy.org/issue1255 for details
parent 467afb8b
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,24 @@ def hang_until_sig(extra_signals=[]): ...@@ -15,6 +15,24 @@ def hang_until_sig(extra_signals=[]):
then also on those signals this call will release.""" then also on those signals this call will release."""
global end global end
# Ascertain what Python are we working on. 2012 PyPy and earlier
# may be affected by https://bugs.pypy.org/issue1255
bugged_pypy = False
try:
import platform
except:
pass
else:
if platform.python_implementation() == 'PyPy':
try:
mon, day, year = platform.python_build()[1].split(' ')
year = int(year)
except:
pass
else:
bugged_pypy = year <= 2012
signal.signal(signal.SIGTERM, __sighandler) signal.signal(signal.SIGTERM, __sighandler)
signal.signal(signal.SIGINT, __sighandler) signal.signal(signal.SIGINT, __sighandler)
for s in extra_signals: for s in extra_signals:
...@@ -22,7 +40,10 @@ def hang_until_sig(extra_signals=[]): ...@@ -22,7 +40,10 @@ def hang_until_sig(extra_signals=[]):
while not end: while not end:
try: try:
signal.pause() if bugged_pypy:
time.sleep(1) # see https://bugs.pypy.org/issue1255
else:
signal.pause()
except: # pause() is undefined on Windows except: # pause() is undefined on Windows
try: # we will sleep for small periods of time try: # we will sleep for small periods of time
time.sleep(0.5) time.sleep(0.5)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment