[svn] commit: r436 - /branches/parkinglot/src/bin/msgq/msgq.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Jan 8 11:45:19 UTC 2010
Author: jelte
Date: Fri Jan 8 11:45:19 2010
New Revision: 436
Log:
fix for msgq; ctrl-c-ing bind10 would sometimes leave the socket connection hanging. Fixed to catch SIGTERM and KeyboardInterrupts to cleanly shut down the msgq (is there a way to do this without a global variable?)
Modified:
branches/parkinglot/src/bin/msgq/msgq.py
Modified: branches/parkinglot/src/bin/msgq/msgq.py
==============================================================================
--- branches/parkinglot/src/bin/msgq/msgq.py (original)
+++ branches/parkinglot/src/bin/msgq/msgq.py Fri Jan 8 11:45:19 2010
@@ -301,6 +301,15 @@
sys.stdout.write("Stopping the server.\n")
self.listen_socket.close()
+# can signal handling and calling a destructor be done without a
+# global variable?
+msgq = None
+
+def signal_handler(signal, frame):
+ if msgq:
+ msgq.shutdown()
+ sys.exit(0)
+
if __name__ == "__main__":
def check_port(option, opt_str, value, parser):
"""Function to insure that the port we are passed is actually
@@ -319,6 +328,8 @@
help="port the msgq daemon will use")
(options, args) = parser.parse_args()
+ signal.signal(signal.SIGTERM, signal_handler)
+
# Announce startup.
if options.verbose:
sys.stdout.write("MsgQ %s\n" % __version__)
@@ -330,6 +341,9 @@
sys.stderr.write("Error on startup: %s\n" % setup_result)
sys.exit(1)
- msgq.run()
+ try:
+ msgq.run()
+ except KeyboardInterrupt:
+ pass
msgq.shutdown()
More information about the bind10-changes
mailing list