Rev 6192: No longer register stop_gracefully for each request, it is handled in http://bazaar.launchpad.net/~jameinel/bzr/2.5-soft-hangup-795025

John Arbash Meinel john at arbash-meinel.com
Fri Sep 23 17:45:27 UTC 2011


At http://bazaar.launchpad.net/~jameinel/bzr/2.5-soft-hangup-795025

------------------------------------------------------------
revno: 6192
revision-id: john at arbash-meinel.com-20110923174515-8ygrre1lrefev9kr
parent: john at arbash-meinel.com-20110923173914-gwkk0a4igocst0fp
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.5-soft-hangup-795025
timestamp: Fri 2011-09-23 19:45:15 +0200
message:
  No longer register stop_gracefully for each request, it is handled
  by the service at the top level.
  However, we need to do something for the inet server, but we want tests for that.
-------------- next part --------------
=== modified file 'bzrlib/smart/medium.py'
--- a/bzrlib/smart/medium.py	2011-09-23 16:40:32 +0000
+++ b/bzrlib/smart/medium.py	2011-09-23 17:45:15 +0000
@@ -45,7 +45,7 @@
     ui,
     urlutils,
     )
-from bzrlib.smart import client, protocol, request, signals, vfs
+from bzrlib.smart import client, protocol, request, vfs
 from bzrlib.transport import ssh
 """)
 from bzrlib import osutils
@@ -226,15 +226,6 @@
         # Keep a reference to stderr because the sys module's globals get set to
         # None during interpreter shutdown.
         from sys import stderr
-        # Note: There is a temptation to do
-        #       signals.register_on_hangup(id(self), self._stop_gracefully)
-        #       However, that creates a temporary object which is a bound
-        #       method. signals._on_sighup is a WeakKeyDictionary so it
-        #       immediately gets garbage collected, because nothing else
-        #       references it. Instead, we need to keep a real reference to the
-        #       bound method for the lifetime of the serve() function.
-        stop_gracefully = self._stop_gracefully
-        signals.register_on_hangup(id(self), stop_gracefully)
         try:
             while not self.finished:
                 server_protocol = self._build_protocol()
@@ -255,8 +246,6 @@
         except Exception, e:
             stderr.write("%s terminating on exception %s\n" % (self, e))
             raise
-        finally:
-            signals.unregister_on_hangup(id(self))
 
     def _stop_gracefully(self):
         """When we finish this message, stop looking for more."""



More information about the bazaar-commits mailing list