Fix support for older gevent versions.
Gevent 1.5 removed the `gevent.signal` alias, but some older versions
do not have the new `signal_handler` function.
@@ -33,7 +33,13 @@ def _handle_interrupt(signum, frame):
sys.exit(0)
-gevent.signal_handler(signal.SIGINT, gevent.kill) # kill any greenlets on ctrl+c
+try:
+ # Kill any greenlets on ctrl+c
+ gevent.signal_handler(signal.SIGINT, gevent.kill)
+except AttributeError:
+ # Legacy (gevent <1.2) support
+ gevent.signal(signal.SIGINT, gevent.kill)
+
signal.signal(signal.SIGINT, _handle_interrupt) # print the message and exit main
