Show More
@@ -20,11 +20,13 Authors: | |||
|
20 | 20 | import errno |
|
21 | 21 | import logging |
|
22 | 22 | import os |
|
23 | import re | |
|
23 | 24 | import select |
|
24 | 25 | import signal |
|
25 | 26 | import socket |
|
26 | 27 | import sys |
|
27 | 28 | import threading |
|
29 | import time | |
|
28 | 30 | import webbrowser |
|
29 | 31 | |
|
30 | 32 | # Third party |
@@ -451,7 +453,20 class NotebookApp(BaseIPythonApplication): | |||
|
451 | 453 | break |
|
452 | 454 | |
|
453 | 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 | 470 | signal.signal(signal.SIGTERM, self._signal_stop) |
|
456 | 471 | |
|
457 | 472 | def _handle_sigint(self, sig, frame): |
@@ -474,6 +489,8 class NotebookApp(BaseIPythonApplication): | |||
|
474 | 489 | A second ^C, or answering 'y' within 5s will cause shutdown, |
|
475 | 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 | 494 | sys.stdout.write("Shutdown Notebook Server (y/[n])? ") |
|
478 | 495 | sys.stdout.flush() |
|
479 | 496 | r,w,x = select.select([sys.stdin], [], [], 5) |
General Comments 0
You need to be logged in to leave comments.
Login now