Mercurial > piecrust2
comparison piecrust/workerpool.py @ 566:8073ae8cb164
bake: Don't re-setup logging for workers unless we're sure we need it.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 10 Oct 2015 23:02:40 -0700 |
parents | 22a230d99621 |
children | 61d606fbc313 |
comparison
equal
deleted
inserted
replaced
565:ff714d7f074d | 566:8073ae8cb164 |
---|---|
45 | 45 |
46 def _real_worker_func(params): | 46 def _real_worker_func(params): |
47 # In a context where `multiprocessing` is using the `spawn` forking model, | 47 # In a context where `multiprocessing` is using the `spawn` forking model, |
48 # the new process doesn't inherit anything, so we lost all our logging | 48 # the new process doesn't inherit anything, so we lost all our logging |
49 # configuration here. Let's set it up again. | 49 # configuration here. Let's set it up again. |
50 from piecrust.main import _pre_parse_chef_args | 50 if (hasattr(multiprocessing, 'get_start_method') and |
51 _pre_parse_chef_args(sys.argv[1:]) | 51 multiprocessing.get_start_method() == 'spawn'): |
52 from piecrust.main import _pre_parse_chef_args | |
53 _pre_parse_chef_args(sys.argv[1:]) | |
52 | 54 |
53 wid = params.wid | 55 wid = params.wid |
54 logger.debug("Worker %d initializing..." % wid) | 56 logger.debug("Worker %d initializing..." % wid) |
55 | 57 |
56 params.inqueue._writer.close() | 58 params.inqueue._writer.close() |