471,349 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,349 software developers and data experts.

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

HI

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)

Thanks
Jay

Sep 12 '07 #1
0 852

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.