474,059 Members | 21,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 939

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2435
by: gnewsg | last post by:
Hi all. I've just finished to write an FTP daemon in Python. To do things well I'd like to write an 'insteller' to permit the end user to 'deeply' install the package inside the system. In details I would like that installer is able to do the following operations: - copy ftpd.py in /usr/bin. - depending on the system, it should be able to determinate where service startup directory is located (for example /etc/init.d) and copy a script...
3
1576
by: PurpleServerMonkey | last post by:
Seeking feedback from group members on a design I'm looking at using in a project. I've created an XML-RPC server and a number of Daemons, the idea is that the XML-RPC server gets a request from a user interface of some sort and then sends data to the Daemon processes to do work. Daemons will also need to feed back task information to the XML-RPC server. For the communications between the Daemons and XML-RPC server I was thinking of...
5
3290
by: Jeffrey Barish | last post by:
As per Stevens/Rago, "file and record locking provides a convenient mutual-exclusion mechanism". They note the convention of putting the lock file in /var/run in a file called <name>.pid, where <nameis the name of the daemon and content is the pid. Seems like a good suggestion as I see pid files from many other daemons there. However, /var/run is owned by root, so it is not possible to write in it without root permission. I could put...
0
347
by: Cameron Simpson | last post by:
On 12Nov2008 14:07, Jeff McNeil <jeff@jmcneil.netwrote: | On Nov 12, 4:57 pm, Jeffrey Barish <jeff_bar...@earthlink.netwrote: | As per Stevens/Rago, "file and record locking provides a convenient | mutual-exclusion mechanism". They note the convention of putting the lock | file in /var/run in a file called <name>.pid, where <nameis the name of | the daemon and content is the pid. Seems like a good suggestion as I see | pid files from...
0
12199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8746
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7905
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6688
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6892
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5451
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
4006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.