This fails very infrequently with gevent. There is a race condition between testing that KeyboardInterrupt was raised and KeyboardInterrupt actually being raised.
[2017/04/25 14:49:04.348] ====================================================================== [2017/04/25 14:49:04.348] FAIL [1.545s]: test_interrupt_signal (test_client.TestClient) [2017/04/25 14:49:04.348] ---------------------------------------------------------------------- [2017/04/25 14:49:04.348] Traceback (most recent call last): [2017/04/25 14:49:04.348] File "/data/mci/4981048096bd07fd117949166a661b7e/src/test/test_client.py", line 860, in test_interrupt_signal [2017/04/25 14:49:04.348] self.assertTrue(raised, "Didn't raise expected KeyboardInterrupt") [2017/04/25 14:49:04.348] AssertionError: False is not true : Didn't raise expected KeyboardInterrupt [2017/04/25 14:49:04.348] Stderr: [2017/04/25 14:49:04.348] Exception in thread pymongo_kill_cursors_thread: [2017/04/25 14:49:04.348] Traceback (most recent call last): [2017/04/25 14:49:04.348] File "/opt/python/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner [2017/04/25 14:49:04.348] self.run() [2017/04/25 14:49:04.348] File "/opt/python/3.6/lib/python3.6/site-packages/gevent/threading.py", line 190, in run [2017/04/25 14:49:04.348] super(Thread, self).run() [2017/04/25 14:49:04.348] File "/opt/python/3.6/lib/python3.6/threading.py", line 864, in run [2017/04/25 14:49:04.348] self._target(*self._args, **self._kwargs) [2017/04/25 14:49:04.348] File "/data/mci/4981048096bd07fd117949166a661b7e/src/pymongo/periodic_executor.py", line 113, in _run [2017/04/25 14:49:04.348] while not self.__should_stop(): [2017/04/25 14:49:04.348] File "/data/mci/4981048096bd07fd117949166a661b7e/src/pymongo/periodic_executor.py", line 106, in __should_stop [2017/04/25 14:49:04.348] with self._lock: [2017/04/25 14:49:04.348] File "src/gevent/_semaphore.py", line 239, in gevent._semaphore.Semaphore.__enter__ (src/gevent/gevent._semaphore.c:4665) [2017/04/25 14:49:04.349] File "src/gevent/_semaphore.py", line 240, in gevent._semaphore.Semaphore.__enter__ (src/gevent/gevent._semaphore.c:4619) [2017/04/25 14:49:04.349] File "src/gevent/_semaphore.py", line 198, in gevent._semaphore.Semaphore.acquire (src/gevent/gevent._semaphore.c:4252) [2017/04/25 14:49:04.349] File "/opt/python/3.6/lib/python3.6/site-packages/gevent/thread.py", line 70, in acquire [2017/04/25 14:49:04.349] def acquire(self, blocking=True, timeout=-1): [2017/04/25 14:49:04.349] File "/data/mci/4981048096bd07fd117949166a661b7e/src/test/test_client.py", line 846, in sigalarm [2017/04/25 14:49:04.349] raise KeyboardInterrupt [2017/04/25 14:49:04.349] KeyboardInterrupt