mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Merged fix added for recent changes in non-threading environments.
This commit is contained in:
commit
323e4fb864
2 changed files with 28 additions and 7 deletions
|
@ -914,9 +914,12 @@ class StreamHandler(Handler):
|
|||
"""
|
||||
Flushes the stream.
|
||||
"""
|
||||
with self.lock:
|
||||
self.acquire()
|
||||
try:
|
||||
if self.stream and hasattr(self.stream, "flush"):
|
||||
self.stream.flush()
|
||||
finally:
|
||||
self.release()
|
||||
|
||||
def emit(self, record):
|
||||
"""
|
||||
|
@ -965,13 +968,16 @@ class FileHandler(StreamHandler):
|
|||
"""
|
||||
Closes the stream.
|
||||
"""
|
||||
with self.lock:
|
||||
self.acquire()
|
||||
try:
|
||||
if self.stream:
|
||||
self.flush()
|
||||
if hasattr(self.stream, "close"):
|
||||
self.stream.close()
|
||||
StreamHandler.close(self)
|
||||
self.stream = None
|
||||
finally:
|
||||
self.release()
|
||||
|
||||
def _open(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue