summaryrefslogtreecommitdiffstats
path: root/Lib/logging/__init__.py
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2012-02-23 20:03:49 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2012-02-23 20:03:49 (GMT)
commit57c223791de6edb7fd302bd682630ab1e259a06b (patch)
tree66db8e9c712e845a2debbd1befc08e5a2c442f5f /Lib/logging/__init__.py
parentc4c90bdf202e9b6d088b7f5a38789b211d9d0a29 (diff)
parent0abf61db4dd0d008ad06c84cd882fb84e5c11181 (diff)
downloadcpython-57c223791de6edb7fd302bd682630ab1e259a06b.zip
cpython-57c223791de6edb7fd302bd682630ab1e259a06b.tar.gz
cpython-57c223791de6edb7fd302bd682630ab1e259a06b.tar.bz2
Merged logging flush/close changes from 3.2.
Diffstat (limited to 'Lib/logging/__init__.py')
-rw-r--r--Lib/logging/__init__.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 8fe5bd9..3bd423d 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -16,9 +16,9 @@
"""
Logging package for Python. Based on PEP 282 and comments thereto in
-comp.lang.python, and influenced by Apache's log4j system.
+comp.lang.python.
-Copyright (C) 2001-2011 Vinay Sajip. All Rights Reserved.
+Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
"""
@@ -914,8 +914,9 @@ class StreamHandler(Handler):
"""
Flushes the stream.
"""
- if self.stream and hasattr(self.stream, "flush"):
- self.stream.flush()
+ with self.lock:
+ if self.stream and hasattr(self.stream, "flush"):
+ self.stream.flush()
def emit(self, record):
"""
@@ -964,12 +965,13 @@ class FileHandler(StreamHandler):
"""
Closes the stream.
"""
- if self.stream:
- self.flush()
- if hasattr(self.stream, "close"):
- self.stream.close()
- StreamHandler.close(self)
- self.stream = None
+ with self.lock:
+ if self.stream:
+ self.flush()
+ if hasattr(self.stream, "close"):
+ self.stream.close()
+ StreamHandler.close(self)
+ self.stream = None
def _open(self):
"""