mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Closes #27930: Merged fix from 3.5.
This commit is contained in:
commit
93e6b3314d
3 changed files with 91 additions and 89 deletions
|
@ -1388,7 +1388,6 @@ if threading:
|
|||
"""
|
||||
self.queue = queue
|
||||
self.handlers = handlers
|
||||
self._stop = threading.Event()
|
||||
self._thread = None
|
||||
self.respect_handler_level = respect_handler_level
|
||||
|
||||
|
@ -1409,7 +1408,7 @@ if threading:
|
|||
LogRecords to process.
|
||||
"""
|
||||
self._thread = t = threading.Thread(target=self._monitor)
|
||||
t.setDaemon(True)
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
def prepare(self , record):
|
||||
|
@ -1448,20 +1447,9 @@ if threading:
|
|||
"""
|
||||
q = self.queue
|
||||
has_task_done = hasattr(q, 'task_done')
|
||||
while not self._stop.isSet():
|
||||
try:
|
||||
record = self.dequeue(True)
|
||||
if record is self._sentinel:
|
||||
break
|
||||
self.handle(record)
|
||||
if has_task_done:
|
||||
q.task_done()
|
||||
except queue.Empty:
|
||||
pass
|
||||
# There might still be records in the queue.
|
||||
while True:
|
||||
try:
|
||||
record = self.dequeue(False)
|
||||
record = self.dequeue(True)
|
||||
if record is self._sentinel:
|
||||
break
|
||||
self.handle(record)
|
||||
|
@ -1488,7 +1476,6 @@ if threading:
|
|||
Note that if you don't call this before your application exits, there
|
||||
may be some records still left on the queue, which won't be processed.
|
||||
"""
|
||||
self._stop.set()
|
||||
self.enqueue_sentinel()
|
||||
self._thread.join()
|
||||
self._thread = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue