Show More
@@ -20,11 +20,13 b' Authors:' | |||||
20 | import errno |
|
20 | import errno | |
21 | import logging |
|
21 | import logging | |
22 | import os |
|
22 | import os | |
|
23 | import re | |||
23 | import select |
|
24 | import select | |
24 | import signal |
|
25 | import signal | |
25 | import socket |
|
26 | import socket | |
26 | import sys |
|
27 | import sys | |
27 | import threading |
|
28 | import threading | |
|
29 | import time | |||
28 | import webbrowser |
|
30 | import webbrowser | |
29 |
|
31 | |||
30 | # Third party |
|
32 | # Third party | |
@@ -451,7 +453,20 b' class NotebookApp(BaseIPythonApplication):' | |||||
451 | break |
|
453 | break | |
452 |
|
454 | |||
453 | def init_signal(self): |
|
455 | def init_signal(self): | |
454 | signal.signal(signal.SIGINT, self._handle_sigint) |
|
456 | # FIXME: remove this check when pyzmq dependency is >= 2.1.11 | |
|
457 | # safely extract zmq version info: | |||
|
458 | try: | |||
|
459 | zmq_v = zmq.pyzmq_version_info() | |||
|
460 | except AttributeError: | |||
|
461 | zmq_v = [ int(n) for n in re.findall(r'\d+', zmq.__version__) ] | |||
|
462 | if 'dev' in zmq.__version__: | |||
|
463 | zmq_v.append(999) | |||
|
464 | zmq_v = tuple(zmq_v) | |||
|
465 | if zmq_v >= (2,1,9): | |||
|
466 | # This won't work with 2.1.7 and | |||
|
467 | # 2.1.9-10 will log ugly 'Interrupted system call' messages, | |||
|
468 | # but it will work | |||
|
469 | signal.signal(signal.SIGINT, self._handle_sigint) | |||
455 | signal.signal(signal.SIGTERM, self._signal_stop) |
|
470 | signal.signal(signal.SIGTERM, self._signal_stop) | |
456 |
|
471 | |||
457 | def _handle_sigint(self, sig, frame): |
|
472 | def _handle_sigint(self, sig, frame): | |
@@ -474,6 +489,8 b' class NotebookApp(BaseIPythonApplication):' | |||||
474 | A second ^C, or answering 'y' within 5s will cause shutdown, |
|
489 | A second ^C, or answering 'y' within 5s will cause shutdown, | |
475 | otherwise original SIGINT handler will be restored. |
|
490 | otherwise original SIGINT handler will be restored. | |
476 | """ |
|
491 | """ | |
|
492 | # FIXME: remove this delay when pyzmq dependency is >= 2.1.11 | |||
|
493 | time.sleep(0.1) | |||
477 | sys.stdout.write("Shutdown Notebook Server (y/[n])? ") |
|
494 | sys.stdout.write("Shutdown Notebook Server (y/[n])? ") | |
478 | sys.stdout.flush() |
|
495 | sys.stdout.flush() | |
479 | r,w,x = select.select([sys.stdin], [], [], 5) |
|
496 | r,w,x = select.select([sys.stdin], [], [], 5) |
General Comments 0
You need to be logged in to leave comments.
Login now