[shpy-commit] r2893 - in shpy/trunk/dist/shpy: net ui_pygame

arigo@codespeak.net arigo@codespeak.net
Fri, 23 Jan 2004 17:07:59 +0100 (MET)


Author: arigo
Date: Fri Jan 23 17:07:59 2004
New Revision: 2893

Modified:
   shpy/trunk/dist/shpy/net/gateway.py
   shpy/trunk/dist/shpy/ui_pygame/ui_pygame.py
Log:
Clean client exit.


Modified: shpy/trunk/dist/shpy/net/gateway.py
==============================================================================
--- shpy/trunk/dist/shpy/net/gateway.py	(original)
+++ shpy/trunk/dist/shpy/net/gateway.py	Fri Jan 23 17:07:59 2004
@@ -17,21 +17,24 @@
             ]
         for t in self.threads:
             t.gateway = self
-            t.setDaemon(1)
+            t.setDaemon(0)
             t.start()
         self.running = 1
 
     def exit(self):
-        self.running = 0
+        self.please_exit_at_some_time_later()
         print "closing i/o connexion"
         self.io.close()
-        print "putting none to queues" 
-        self.incoming.put(None)
-        self.outgoing.put(None)
         for t in self.threads:
             print "joining thread", t
             t.join(10.0)
 
+    def please_exit_at_some_time_later(self):
+        self.running = 0
+        print "putting none to queues"
+        self.incoming.put(None)
+        self.outgoing.put(None)
+
     def __nonzero__(self):
         return self.running
 
@@ -94,7 +97,7 @@
                 string = recv(stringlen)
                 self.queue.put(string)
         except (EOFError, socket.error):
-            pass
+            self.gateway.please_exit_at_some_time_later()
 
 
 class QueueExecutor(threading.Thread):

Modified: shpy/trunk/dist/shpy/ui_pygame/ui_pygame.py
==============================================================================
--- shpy/trunk/dist/shpy/ui_pygame/ui_pygame.py	(original)
+++ shpy/trunk/dist/shpy/ui_pygame/ui_pygame.py	Fri Jan 23 17:07:59 2004
@@ -234,6 +234,9 @@
     K_HOME = CTRL_K_a
     K_END = CTRL_K_e
 
+    def CTRL_K_d(self, event):
+        sys.exit()
+
     def CTRL_K_k(self, event):
         x, line = self.cursor.xline()
         for c in line.content[x:]:
@@ -338,8 +341,9 @@
                 self.invalid = True
 
     def close(self):
-        print "trying to quit the gateway ..."
+        print "trying to quit the gateways ..."
         self.servergateway.exit()
+        self.execgateway.exit()
         print "calling pygame.quit()"
         pygame.quit()
 
@@ -353,7 +357,7 @@
     if len(sys.argv) > 2:
         execserver = sys.argv[2]
     else:
-        execserver = 'popen=python -u -c "exec input(); import time; time.sleep(999)"'
+        execserver = 'popen=python -u -c "exec input()"'
     t = Terminal(sharedserver, execserver)
     try:
         t.run()