Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 2.7.15 doesn't respect swallow_exc #20

Open
ferdinandvanwyk opened this issue Feb 19, 2019 · 1 comment
Open

Python 2.7.15 doesn't respect swallow_exc #20

ferdinandvanwyk opened this issue Feb 19, 2019 · 1 comment

Comments

@ferdinandvanwyk
Copy link

Running the following simple code with python 2.7.15:

from stopit import ThreadingTimeout                                                                                     
                                                                                                                        
def func():                                                                                                             
    with ThreadingTimeout(1, swallow_exc=True):                                                                         
        import time; time.sleep(2)                                                                                      
                                                                                                                         
if __name__ == '__main__':                                                                                               
    func()

I get the following exception being thrown:

Traceback (most recent call last):
  File "main.py", line 8, in <module>
    func()
  File "main.py", line 5, in func
    import time; time.sleep(2)
  File "py_envs/py2/lib/python2.7/site-packages/stopit/utils.py", line 87, in __exit__
    self.suppress_interrupt()
  File "py_envs/py2/lib/python2.7/site-packages/stopit/threadstop.py", line 65, in suppress_interrupt
    self.timer.cancel()
  File "homebrew/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 1066, in cancel
    def cancel(self):
stopit.utils.TimeoutException

When I run with python 3 I don't get any output as expected, because I've swallowed the exception. Any ideas?

@ferdinandvanwyk ferdinandvanwyk changed the title Python 2.7.15 respect swallow_exc Python 2.7.15 doesn't respect swallow_exc Feb 19, 2019
@timjstewart
Copy link

I had a similar issue. For me it was just the stopit log messages getting written to my console. This cleared it up for me:

import logging
stopit_logger = logging.getLogger('stopit')
stopit_logger.setLevel(logging.ERROR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants