OLD | NEW |
1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 continue | 177 continue |
178 method = getattr(self, '_handle_' + message.name) | 178 method = getattr(self, '_handle_' + message.name) |
179 assert method, 'bad message %s' % repr(message) | 179 assert method, 'bad message %s' % repr(message) |
180 method(message.src, *message.args) | 180 method(message.src, *message.args) |
181 except Queue.Empty: | 181 except Queue.Empty: |
182 pass | 182 pass |
183 | 183 |
184 | 184 |
185 class WorkerException(BaseException): | 185 class WorkerException(BaseException): |
186 """Raised when we receive an unexpected/unknown exception from a worker.""" | 186 """Raised when we receive an unexpected/unknown exception from a worker.""" |
187 pass | |
188 | 187 |
189 | 188 |
190 class _Message(object): | 189 class _Message(object): |
191 | 190 |
192 def __init__(self, src, message_name, message_args, from_user, logs): | 191 def __init__(self, src, message_name, message_args, from_user, logs): |
193 self.src = src | 192 self.src = src |
194 self.name = message_name | 193 self.name = message_name |
195 self.args = message_args | 194 self.args = message_args |
196 self.from_user = from_user | 195 self.from_user = from_user |
197 self.logs = logs | 196 self.logs = logs |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 322 |
324 class _WorkerLogHandler(logging.Handler): | 323 class _WorkerLogHandler(logging.Handler): |
325 | 324 |
326 def __init__(self, worker): | 325 def __init__(self, worker): |
327 logging.Handler.__init__(self) | 326 logging.Handler.__init__(self) |
328 self._worker = worker | 327 self._worker = worker |
329 self.setLevel(worker.log_level) | 328 self.setLevel(worker.log_level) |
330 | 329 |
331 def emit(self, record): | 330 def emit(self, record): |
332 self._worker.log_messages.append(record) | 331 self._worker.log_messages.append(record) |
OLD | NEW |