Message159046
> Charles-François: Certainly I can reduce the iterations to make the test
> faster. As it is, I did reproduce the failure on my dev system, but only
> once, after running John's test script about a dozen times: every other
> time, it completed successfully :-(
Juste reduce the sleep times, e.g.:
"""
@@ -17,7 +17,7 @@
os.unlink(fname)
except OSError:
pass
- stime = 0.04 * random.randint(0, 4)
+ stime = 0.004 * random.randint(0, 4)
time.sleep(stime)
@@ -50,7 +50,7 @@
log.setLevel(logging.INFO)
for ii in range(LOGCOUNT):
- stime = 0.05 # * random.randint(0, 4)
+ stime = 0.005 # * random.randint(0, 4)
time.sleep(stime)
log.warning('Foo bar %d', ii)
"""
With this change, I can trigger a failure reliably in around 1s, and
my computer is rather slow.
> Isn't it simpler if I just replace the os.path.exists() calls with
> os.stat(), and check for ENOENT if an exception of type OSError or
> WindowsError occurs?
The problem is that it would leave a race window if the file is
changed between the time it's opened (I guess in
logging.FileHandler.__init__()) and the first call to stat().
John's patch is safe in this regard, thanks to fstat(). |
|
Date |
User |
Action |
Args |
2012-04-23 17:05:36 | neologix | set | recipients:
+ neologix, vinay.sajip, phlogistonjohn |
2012-04-23 17:05:35 | neologix | link | issue14632 messages |
2012-04-23 17:05:35 | neologix | create | |
|