Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > 2 daemons write to a single file /w python file IO

Thread Tools

2 daemons write to a single file /w python file IO

Posts: n/a

i have a newbie question about the file() function.
I have 2 daemons running on my linux box.

1 will record the IDs to a file - logs.txt
other 1 will open this file, read the IDs, and then "Clean up the
file" -logs.txt

Since these 2 daemons will run every 2-5mins, I think this will crash, isn't
it? When both daemons try to write to the file at the same time.

I am wondering if this won't crash, OR if there is some simple high-level
functions can lock the file while writing...
I also wonder if one side locked the file, what happens if the other side
try to open this locked file? raise error? so i also need to write a loop to
wait for the file to release locking?

seems a basic easy thing but i just cannot find an simple answer.
I always advoid this issue by putting them in mysql (well, fast and hassle
free for locking)


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Single-instance daemons Jeffrey Barish Python 5 11-17-2008 05:15 AM
Python, Daemons and D-Bus PurpleServerMonkey Python 3 05-25-2008 11:40 AM
Thin errors out -> `gem_original_require': no such file to load --daemons Junkone Ruby 1 02-16-2008 03:00 PM
Re: 2 daemons write to a single file /w python file IO Steven W. Orr Python 0 09-14-2007 08:52 PM
How to write UNIX daemons in Python? Python 2 09-13-2006 03:38 PM