changeset 33:d8d44216258a

Exit the slave script when the master disconnects; and other minor fixes.
author cmlenz
date Tue, 21 Jun 2005 08:53:43 +0000
parents 21c52720ed32
children 6da9468a6879
files bitten/master.py bitten/slave.py bitten/util/beep.py
diffstat 3 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/master.py
+++ b/bitten/master.py
@@ -96,7 +96,7 @@
     parser.add_option('-p', '--port', action='store', type='int', dest='port',
                       help='port number to use')
     parser.add_option('-H', '--host', action='store', dest='host',
-                      help='the host name of IP address to bind to')
+                      help='the host name or IP address to bind to')
     parser.add_option('--debug', action='store_const', dest='loglevel',
                       const=logging.DEBUG, help='enable debugging output')
     parser.add_option('-v', '--verbose', action='store_const', dest='loglevel',
@@ -129,7 +129,8 @@
     try:
         master.run()
     except KeyboardInterrupt:
+        # FIXME: gracefully shutdown all active sessions
         pass
 
 if __name__ == '__main__':
-    main()
\ No newline at end of file
+    main()
--- a/bitten/slave.py
+++ b/bitten/slave.py
@@ -99,4 +99,4 @@
     slave.run()
 
 if __name__ == '__main__':
-    main()
\ No newline at end of file
+    main()
--- a/bitten/util/beep.py
+++ b/bitten/util/beep.py
@@ -23,7 +23,8 @@
 
 Current limitations:
  * No support for the TSL and SASL profiles.
- * No support for mapping frames (SEQ frames for TCP mapping). 
+ * No support for mapping frames (SEQ frames for TCP mapping).
+ * No localization support (xml:lang attribute).
 """
 
 import asynchat
@@ -149,6 +150,10 @@
         self.channelno = cycle_through(first_channelno, 2147483647, step=2)
         self.channels = {0: Channel(self, 0, ManagementProfileHandler)}
 
+    def handle_close(self):
+        logging.debug('Connection closed by peer')
+        self.close()
+
     def handle_connect(self):
         """Called by asyncore when the connection is established."""
 
@@ -299,6 +304,7 @@
     def handle_close(self):
         """Called by asyncore when the socket has been closed."""
         self.terminated = True
+        Session.handle_close(self)
 
     def greeting_received(self, profiles):
         """Sub-classes should override this to start the channels they need.
@@ -644,7 +650,16 @@
         self.channel.send_err(msgno, MIMEMessage(xml))
 
     def send_start(self, profiles, handle_ok=None, handle_error=None):
-        """Send a request to start a new channel to the peer."""
+        """Send a request to start a new channel to the peer.
+        
+        @param profiles A list of profiles to request for the channel, each
+                        element being an instance of a `ProfileHandler`
+                        sub-class
+        @param handle_ok An optional callback function that will be invoked when
+                         the channel has been successfully started
+        @param handle_error An optional callback function that will be invoked
+                            when the peer refuses to start the channel
+        """
         channelno = self.session.channelno.next()
         def handle_reply(cmd, msgno, message):
             if cmd == 'RPY':
Copyright (C) 2012-2017 Edgewall Software