Race condition when generating .pyc files
Aaron "Castironpi" Brady
castironpi at gmail.com
Tue Oct 7 12:43:06 EDT 2008
On Oct 7, 10:21 am, "yogamatt1... at gmail.com" <yogamatt1... at gmail.com>
wrote:
> I have a large body of Python code which runs on many different (Unix)
> machines concurrently. Part of the code lives in one place, but most
> of it lives in directories which I find at runtime. I only have one
> copy of each Python source file and I think I'm hitting a race
> condition where two hosts attempt to import the same module at the
> same time. My import fails on one of the machines and the following
> exception is thrown:
> EOFError: EOF read where object expected
> My hypothesis is that there's contention between the two (or more)
> hosts when the module's .pyc file is generated.
Acquire an flock on the .py file, then compile it.
More information about the Python-list
mailing list