diff options
author | amartin <olpc@xo-05-28-21.localdomain> | 2007-12-27 11:17:05 (GMT) |
---|---|---|
committer | amartin <olpc@xo-05-28-21.localdomain> | 2007-12-27 11:17:05 (GMT) |
commit | 2c4b152bd5dc6d9591a09ada861ec6c39410adac (patch) | |
tree | 1415a7dc2ba7e54e0625102ff0937a26940059f8 | |
parent | 32a03b1c90a0df81f97104a671dddaa137b634af (diff) |
network
-rw-r--r-- | TamTamJam.activity/Jam/JamMain.py | 2 | ||||
-rw-r--r-- | common/Util/Network.py | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/TamTamJam.activity/Jam/JamMain.py b/TamTamJam.activity/Jam/JamMain.py index a8aad03..c875d68 100644 --- a/TamTamJam.activity/Jam/JamMain.py +++ b/TamTamJam.activity/Jam/JamMain.py @@ -331,6 +331,8 @@ class JamMain(gtk.EventBox): pass def onDestroy( self ): + self.network.shutdown() + #clear up scratch folder path = Config.SCRATCH_DIR filelist = os.listdir( path ) diff --git a/common/Util/Network.py b/common/Util/Network.py index 992f570..79fbab5 100644 --- a/common/Util/Network.py +++ b/common/Util/Network.py @@ -22,7 +22,7 @@ import gtk import gobject import common.Config as Config -PORT = 24420 +PORT = 24460 LISTENER_PORT = PORT-1 WAIT_PORT = PORT-2 @@ -80,7 +80,9 @@ class Listener( threading.Thread ): def run(self): while 1: # rely on the owner to kill us when necessary try: - inputReady, outputReady, exceptReady = select.select( self.inputSockets, self.outputSockets, self.exceptSockets ) + inputReady, outputReady, exceptReady = select.select( self.inputSockets, self.outputSockets, self.exceptSockets, 0.5 ) + if not len( inputReady ): # timeout + continue if self.listenerSocket in inputReady: data, s = self.listenerSocket.recvfrom(MAX_SIZE) if data == "REFRESH": @@ -91,7 +93,7 @@ class Listener( threading.Thread ): else: break # exit thread gtk.gdk.threads_enter() - self.owner._processSockets( inputReady, outputReady, exceptReady ) + self.owner._processSockets( inputReady ) gtk.gdk.threads_leave() except socket.error, (value, message): print "Listener:: socket error: " + message @@ -162,6 +164,7 @@ class Network: if self.listener: self.listenerSocket.sendto( "EXIT", ("localhost",LISTENER_PORT) ) time.sleep(0.01) # get off the cpu so the listerer thread has a chance to clear.. IS THERE A BETTER WAY TO DO THIS? + self.listener = None if self.mode == MD_HOST: for s in self.inputSockets: @@ -463,7 +466,7 @@ class Network: #----------------------------------------------------------------------- # Message Handlers - def _processSockets( self, inputReady, outputReady, exceptReady ): + def _processSockets( self, inputReady ): self._fromListener = True |