Try to address dict changing during iteration

```
06:10:57        RuntimeError: dictionary changed size during iteration
06:10:57        Traceback (most recent call last):
06:10:57          File "/usr/lib64/python2.7/multiprocessing/queues.py", line 266, in _feed
06:10:57            send(obj)
06:10:57        RuntimeError: dictionary changed size during iteration
```
This commit is contained in:
Pedro Algarvio 2019-04-30 09:57:05 +01:00
parent c58af57bc0
commit 962b116874
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF

View file

@ -178,7 +178,9 @@ LOGGING_STORE_HANDLER = __StoreLoggingHandler()
class SaltLogQueueHandler(QueueHandler):
pass
def prepare(self, record):
record = QueueHandler.prepare(self, record)
return record.__dict__.copy()
class SaltLogRecord(logging.LogRecord):
@ -1112,12 +1114,13 @@ def __process_multiprocessing_logging_queue(opts, queue):
setup_extended_logging(opts)
while True:
try:
record = queue.get()
if record is None:
record_dict = queue.get()
if record_dict is None:
# A sentinel to stop processing the queue
break
# Just log everything, filtering will happen on the main process
# logging handlers
record = logging.makeLogRecord(record_dict)
logger = logging.getLogger(record.name)
logger.handle(record)
except (EOFError, KeyboardInterrupt, SystemExit):