This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author neologix
Recipients neologix, phlogistonjohn, vinay.sajip
Date 2012-04-23.17:05:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
> 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 @@
         except OSError:
-        stime = 0.04 * random.randint(0, 4)
+        stime = 0.004 * random.randint(0, 4)

@@ -50,7 +50,7 @@

         for ii in range(LOGCOUNT):
-            stime = 0.05 # * random.randint(0, 4)
+            stime = 0.005 # * random.randint(0, 4)
             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:36neologixsetrecipients: + neologix, vinay.sajip, phlogistonjohn
2012-04-23 17:05:35neologixlinkissue14632 messages
2012-04-23 17:05:35neologixcreate