Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

py.test hangs after showing test results

Tags:

pytest

I'm using py.test to run a bunch of tests. The tests seem to pass, but the process never terminates:

===== test session starts =====

platform win32 -- Python 2.7.3 -- pytest-2.3.4

collected 179 items

common/tests/test_bar.py ...............

common/tests/test_foo.py .......

....

===== 159 passed, 20 skipped in 98.58 seconds =====

<-- the prompt never gets back -->

Any ideas what can cause this and how to debug?

EDIT

@hpk42 is right - it was a non-daemon thread that never terminated.

like image 732
bavaza Avatar asked Oct 07 '13 07:10

bavaza


1 Answers

It's likely that your tests start a thread with server loops. If that is the case, you may use thread.setDaemon(True) which marks the thread as "can be thrown away" and might help to get through the Python shutdown. Ideally, though, you should rather signal to your thread/loop that it should terminate.

like image 158
hpk42 Avatar answered Sep 16 '22 19:09

hpk42