Changeset 445

Show
Ignore:
Timestamp:
05/08/08 10:19:56 (8 months ago)
Author:
mgoldman
Message:

communication refactor phase 2

Note: this should not have had an effect on current workingness

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/trunk-pmd-intproto/server/master.py

    r444 r445  
    3434        root_layer.update() 
    3535 
     36def ret2(a,b): 
     37        return b 
    3638 
    3739class Master: 
     
    137139 
    138140        def service_manager(self, (mgr, info)): 
     141                ''' 
     142                Handle servicing of a manager connection.  In general, we read 
     143                a request from the manager.   
     144                 
     145                If the request is one of a couple 
     146                of types handled internally by the server, process the request 
     147                and send the results back to the manager. (This may or may not 
     148                interact with one or more clients.) 
     149 
     150                If the request is of an unknown type, pass the message along to 
     151                clients.  Collect the results from each client and packagge 
     152                them up in a message.  Send this back to the manager. 
     153                ''' 
    139154                try: 
    140155                        print "Servicing " + repr(info) 
     
    155170                                        res = self.storeadd((mgr, info), val) 
    156171                                elif val.msg == 'remove': 
    157                                         res = val 
     172                                        res = self.storeremove((mgr, info), val) 
    158173                                else: 
    159                                         self.clients.send_all(val) 
    160                                         res = [] 
    161                                         for (c, i) in self.clients.get_clients().items(): 
    162                                                 ret = pickle.load(c.makefile()) 
    163                                                 res.append((ret, i)) 
     174                                        res = comm(ret2, val, (mgr, info)) 
    164175                                pickle.dump(res, mgr.makefile()) 
    165176                                return res 
     
    215226                n.update() 
    216227                return True 
     228         
     229        def comm(self, func, msg, (mgr, info)): 
     230                target = val.targets 
     231                val.targets = None 
     232                if target == None: 
     233                        val = func((mgr, info), msg) 
     234                        self.clients.send_all(val) 
     235                        res = [] 
     236                        for (c, i) in self.clients.get_clients().items(): 
     237                                ret = pickle.load(c.makefile()) 
     238                                res.append((ret, i)) 
     239                else: 
     240                        print "This section unfinished." 
     241                        raise NotImplementedError 
     242                return res 
    217243 
    218244        def run(self):