Alex Rivera | Logout

Locking a file in Python

Asked 2009-01-28T23:20:03.990
227

I need to lock a file for writing in Python. It will be accessed from multiple Python processes at once. I have found some solutions online, but most fail for my purposes as they are often only Unix based or Windows based.

Edit
Report

1 Answer

7

Coordinating access to a single file at the OS level is fraught with all kinds of issues that you probably don't want to solve.

Your best bet is have a separate process that coordinates read/write access to that file.

answered 2009-01-29T00:24:06.857

Your Answer