Changeset 445
- 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
| r444 |
r445 |
|
| 34 | 34 | root_layer.update() |
|---|
| 35 | 35 | |
|---|
| | 36 | def ret2(a,b): |
|---|
| | 37 | return b |
|---|
| 36 | 38 | |
|---|
| 37 | 39 | class Master: |
|---|
| … | … | |
| 137 | 139 | |
|---|
| 138 | 140 | 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 | ''' |
|---|
| 139 | 154 | try: |
|---|
| 140 | 155 | print "Servicing " + repr(info) |
|---|
| … | … | |
| 155 | 170 | res = self.storeadd((mgr, info), val) |
|---|
| 156 | 171 | elif val.msg == 'remove': |
|---|
| 157 | | res = val |
|---|
| | 172 | res = self.storeremove((mgr, info), val) |
|---|
| 158 | 173 | 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)) |
|---|
| 164 | 175 | pickle.dump(res, mgr.makefile()) |
|---|
| 165 | 176 | return res |
|---|
| … | … | |
| 215 | 226 | n.update() |
|---|
| 216 | 227 | 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 |
|---|
| 217 | 243 | |
|---|
| 218 | 244 | def run(self): |
|---|
Download in other formats:
* Generating other formats may take time.