From 0a3d5568db95748eef76ae76fac4df0436a51e2c Mon Sep 17 00:00:00 2001 From: henrietta <piotr.maslanka@henrietta.com.pl> Date: Fri, 19 Jul 2013 15:55:01 +0200 Subject: [PATCH] workaround for issue 1255 in PyPy see https://bugs.pypy.org/issue1255 for details --- unix/__init__.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/unix/__init__.py b/unix/__init__.py index e934dde7..3d2fd06f 100644 --- a/unix/__init__.py +++ b/unix/__init__.py @@ -15,6 +15,24 @@ def hang_until_sig(extra_signals=[]): then also on those signals this call will release.""" 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.SIGINT, __sighandler) for s in extra_signals: @@ -22,7 +40,10 @@ def hang_until_sig(extra_signals=[]): while not end: try: - signal.pause() + if bugged_pypy: + time.sleep(1) # see https://bugs.pypy.org/issue1255 + else: + signal.pause() except: # pause() is undefined on Windows try: # we will sleep for small periods of time time.sleep(0.5) -- GitLab