CleanCut / green

Green is a clean, colorful, fast python test runner.
MIT License
793 stars 75 forks source link

Catch not working #169

Closed davidhyman closed 6 years ago

davidhyman commented 7 years ago

Once I start a test run I have to wait for completion - because ctrl-c doesn't seem to do the job :(

I see it's meant to! https://github.com/CleanCut/green/issues/5

What I get instead is a hang And if I'm impatient and press ctrl-c again, I end up in a state where I see KeyboardInterrupt tracebacks from CProcess DaemonlessPoolWorker-160: (that number keeps going up each time I press ctrl-c) e.g.

Process DaemonlessPoolWorker-161:
Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python2.7/dist-packages/green/process.py", line 179, in worker
    task = get()
  File "/usr/lib/python2.7/multiprocessing/queues.py", line 374, in get
    racquire()
  File "/usr/lib/python2.7/unittest/signals.py", line 36, in __call__
    self.default_handler(signum, frame)
KeyboardInterrupt

What I would expect on the second ctrl-c is a complete termination of all child workers - somehow the Pool isn't being killed.

I'm not doing anything special with green itself beyond running green some.test.module. One potential compounding factor for me is that this is via docker rather than native ubuntu - but it's clearly receiving signals.

CleanCut commented 7 years ago

Yes, I've noticed this myself. It's definitely a bug. I'm not sure what's going on yet. If anyone else has any ideas, please let me know.

CleanCut commented 7 years ago

I took some time and tried investigating this...but I can't reproduce the condition! For me, the first Ctrl-C either ends everything or causes the test run to end after the current running test is running (depending on what's going on when it's pressed). If the current running test is very long and I press Ctrl-C a second time, then everything stops.

Can you provide me a set of tests that I can duplicate the behavior with?

Signal handling in Python is really flaky. It's made much worse since unittest plays with it as well.

CleanCut commented 6 years ago

Closing due to inactivity.

Feel free to reopen this if you have some sample code that can help reproduce the problem.