summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-04-26 00:18:24 (GMT)
committerBrett Cannon <brett@python.org>2012-04-26 00:18:24 (GMT)
commit5a5d6a10333af38c753b82f8d1bef14906c12b61 (patch)
tree9bc3c6d28e29f08646775fec90e8b5000a633f02 /Lib/test
parent8923a4d4c514a621b7f99ee0f3ebdde319aee0e9 (diff)
parent718fbf078cef405318dc712a2c32fbc12e87de02 (diff)
downloadcpython-5a5d6a10333af38c753b82f8d1bef14906c12b61.zip
cpython-5a5d6a10333af38c753b82f8d1bef14906c12b61.tar.gz
cpython-5a5d6a10333af38c753b82f8d1bef14906c12b61.tar.bz2
Merge
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_logging.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index ee1c211..2279952 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -593,28 +593,28 @@ class HandlerTest(BaseTest):
pass
time.sleep(0.004 * random.randint(0, 4))
- def cleanup(remover, fn, handler):
- handler.close()
- remover.join()
- if os.path.exists(fn):
- os.unlink(fn)
+ del_count = 500
+ log_count = 500
- fd, fn = tempfile.mkstemp('.log', 'test_logging-3-')
- os.close(fd)
- del_count = 1000
- log_count = 1000
- remover = threading.Thread(target=remove_loop, args=(fn, del_count))
- remover.daemon = True
- remover.start()
for delay in (False, True):
+ fd, fn = tempfile.mkstemp('.log', 'test_logging-3-')
+ os.close(fd)
+ remover = threading.Thread(target=remove_loop, args=(fn, del_count))
+ remover.daemon = True
+ remover.start()
h = logging.handlers.WatchedFileHandler(fn, delay=delay)
- self.addCleanup(cleanup, remover, fn, h)
f = logging.Formatter('%(asctime)s: %(levelname)s: %(message)s')
h.setFormatter(f)
- for _ in range(log_count):
- time.sleep(0.005)
- r = logging.makeLogRecord({'msg': 'testing' })
- h.handle(r)
+ try:
+ for _ in range(log_count):
+ time.sleep(0.005)
+ r = logging.makeLogRecord({'msg': 'testing' })
+ h.handle(r)
+ finally:
+ h.close()
+ remover.join()
+ if os.path.exists(fn):
+ os.unlink(fn)
class BadStream(object):