Skip to content

Python 2.7.15 doesn't respect swallow_exc #20

@ferdinandvanwyk

Description

@ferdinandvanwyk

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions