Re: Caches, caches...

Sjoerd Mullender (Sjoerd.Mullender@cwi.nl)
Fri, 18 Mar 1994 10:56:26 +0100

On Wed, Mar 16 1994 Guido.van.Rossum@cwi.nl wrote:

> > This brings up another interesting point: are the .pyc files guarded agains
> t
> > concurrent generation?
>
> Yes. The timestamp and magic number are written last, in one write
> operation.

As stated, this is not enough. It can happen that two processes start
writing the same .pyc file at the same time. I suppose that usually
the two processes will write identical copies, but when there are
different versions of python around, that may not be the case.

A better approach would be to write to a temporary file first and
linking the temporary file to the .pyc file at the end. When linking
fails, someone else was there before you, so you can ignore the error.

Sjoerd Mullender, CWI, P.O. Box 94079, 1090 GB Amsterdam, The Netherlands
E-Mail: Sjoerd.Mullender@cwi.nl; Phone: +31 20 592 4127; Fax: +31 20 592 4199
URL: <http://www.cwi.nl/cwi/people/Sjoerd.Mullender.html>