A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/335105.html below:

Putting a lock on file.

Putting a lock on file. Putting a lock on file.Harlin Seritt harlinseritt at yahoo.com
Sun Sep 18 02:58:58 EDT 2005
I have a file that a few different running scripts will need to access.
Most likely this won't be a problem but if it is, what do I need to do
to make sure scripts don't crash because the input file is in use?
Would it be best to run a loop like the following:

flag = 0
while not flag:
    try:
        open(file, 'r').read()
        flag = 1
    except:
        pass

This may seem nice on paper but I hate to run a while for an
indeterminate amount of time. Is there anything else that can be done
that would be better?

Thanks,

Harlin Seritt


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4