Mercurial > piecrust2
comparison piecrust/workerpool.py @ 453:8351a77e13f5
bake: Don't pass the previous record entries to the workers.
Workers now load the previous record on their own and find the previous
entry in their own copy.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 07 Jul 2015 20:19:54 -0700 |
parents | 838f3964f400 |
children | 55fc8918cb75 |
comparison
equal
deleted
inserted
replaced
452:55026b7bb1bf | 453:8351a77e13f5 |
---|---|
48 wid = params.wid | 48 wid = params.wid |
49 logger.debug("Worker %d initializing..." % wid) | 49 logger.debug("Worker %d initializing..." % wid) |
50 | 50 |
51 w = params.worker_class(*params.initargs) | 51 w = params.worker_class(*params.initargs) |
52 w.wid = wid | 52 w.wid = wid |
53 w.initialize() | 53 try: |
54 w.initialize() | |
55 except Exception as ex: | |
56 logger.error("Working failed to initialize:") | |
57 logger.exception(ex) | |
58 params.outqueue.put(None) | |
59 return | |
54 | 60 |
55 get = params.inqueue.get | 61 get = params.inqueue.get |
56 put = params.outqueue.put | 62 put = params.outqueue.put |
57 | 63 |
58 completed = 0 | 64 completed = 0 |
150 if self._closed: | 156 if self._closed: |
151 raise Exception("This worker pool has been closed.") | 157 raise Exception("This worker pool has been closed.") |
152 if self._listener is not None: | 158 if self._listener is not None: |
153 raise Exception("A previous job queue has not finished yet.") | 159 raise Exception("A previous job queue has not finished yet.") |
154 | 160 |
161 if any([not p.is_alive() for p in self._pool]): | |
162 raise Exception("Some workers have prematurely exited.") | |
163 | |
155 if handler is not None: | 164 if handler is not None: |
156 self.setHandler(handler) | 165 self.setHandler(handler) |
157 | 166 |
158 if not hasattr(jobs, '__len__'): | 167 if not hasattr(jobs, '__len__'): |
159 jobs = list(jobs) | 168 jobs = list(jobs) |