conduit r1205 - in trunk: . conduit/modules/NetworkModule



Author: jstowers
Date: Sun Jan 13 02:52:51 2008
New Revision: 1205
URL: http://svn.gnome.org/viewvc/conduit?rev=1205&view=rev

Log:
Be more robust when dataproviders become available or unavailable

Modified:
   trunk/ChangeLog
   trunk/conduit/modules/NetworkModule/Client.py
   trunk/conduit/modules/NetworkModule/Server.py

Modified: trunk/conduit/modules/NetworkModule/Client.py
==============================================================================
--- trunk/conduit/modules/NetworkModule/Client.py	(original)
+++ trunk/conduit/modules/NetworkModule/Client.py	Sun Jan 13 02:52:51 2008
@@ -9,6 +9,7 @@
 import time
 import gobject
 import logging
+import socket
 log = logging.getLogger("modules.Network")
 
 import Peers
@@ -78,15 +79,14 @@
                 self.dataprovider_removed(dp)
             self.dataproviders.remove(url)
                     
-    def dataprovider_process(self, huh, response):
+    def dataprovider_process(self, peerLister):
         """
         """
-        # get some local refs
-        hostUrl = response.url
+        hostUrl = peerLister.url
         currentSharedDps = self.dataproviders[hostUrl]
         #A remote dps uid is the url + the original dp uid
         remoteSharedDps = {}
-        for dpInfo in response.data_out:
+        for dpInfo in peerLister.data_out:
             remoteUid = "%s-%s" % (hostUrl,dpInfo['uid'])
             remoteSharedDps[remoteUid] = dpInfo
 
@@ -149,8 +149,7 @@
     """
     __gsignals__ =  { 
                     "complete": 
-                        (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [
-                        gobject.TYPE_PYOBJECT])      #request,
+                        (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
                     }
 
     FREQ = 5
@@ -172,9 +171,14 @@
         #Gross cancellable spinning loop...
         while not self.stopped:
             while self._ticks > (self.FREQ / self.SLEEP):
-                self.data_out = server.list_shared_dataproviders()
-                gobject.idle_add(self.emit, "complete", self)
-                self._ticks = 0
+                try:
+                    self.data_out = server.list_shared_dataproviders()
+                    gobject.idle_add(self.emit, "complete")
+                    self._ticks = 0
+                except socket.error:
+                    #If the server has died or not started yet
+                    pass
+                                   
             else:
                 time.sleep(self.SLEEP)
                 self._ticks += 1

Modified: trunk/conduit/modules/NetworkModule/Server.py
==============================================================================
--- trunk/conduit/modules/NetworkModule/Server.py	(original)
+++ trunk/conduit/modules/NetworkModule/Server.py	Sun Jan 13 02:52:51 2008
@@ -83,7 +83,7 @@
     def _dataprovider_added(self, cond, dpw):
         sharedDpw,networkEndpoint = self._get_shared_dps(cond)
         if sharedDpw != None:
-            if sharedDpw.get_UID() not in self.shared:
+            if sharedDpw.get_UID() not in self.shared and sharedDpw.module != None:
                 #Update the network enpoint to have the same input and output
                 #types as the shared DP. The proper solution here is to
                 #have the network endpoint also be a client to the remote dp,
@@ -96,6 +96,7 @@
     def _dataprovider_removed(self, cond, dpw):
         if dpw.get_UID() in self.shared:
             self.unshare_dataprovider(dpw)
+            cond._parameters_changed()
             
     def list_shared_dataproviders(self):
         info = []



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]