473,545 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multiple clients updating same file in ftp

hi all

am updating the same file in ftp, through multiple clients, but am
scared that two clients may open the same file at a time, and try
updating, then the data updated by one data will be lost.
So i have to provide some lock mechanism to that file in ftp, so how
can i lock it, if one client opens it for updating, so that till it
gets relased it cannot be updated by other clients.
Could u please suggest me the simple solutions through the python code.

thanks for the help
Yogi

Jan 5 '06 #1
6 4064
here's a simple-minded suggestion: have the first client create a text
file on the remote server, and delete it when it is finished updating.
The second client can check for existence of this file before trying to
update.

cheers,
S

Jan 5 '06 #2
"st************ ***@gmail.com" <st************ ***@gmail.com> writes:
here's a simple-minded suggestion: have the first client create a text
file on the remote server, and delete it when it is finished updating.
The second client can check for existence of this file before trying to
update.


That's an old hack, dating back to at least Unix v6. The problem is
the window between "check for lock file" and "create lock file." The
solution is to use an atomic create-or-fail action for the lock
file. Exatly what that is will depend on your server, but things to
check on are rename and mkdir.

<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 5 '06 #3
why, that's the nicest thing anyone's said about me today - and
probably true, since I started coding on punch-cards...

s

Jan 5 '06 #4

Mike Meyer wrote:
"st************ ***@gmail.com" <st************ ***@gmail.com> writes:
here's a simple-minded suggestion: have the first client create a text
file on the remote server, and delete it when it is finished updating.
The second client can check for existence of this file before trying to
update.
That's an old hack, dating back to at least Unix v6. The problem is
the window between "check for lock file" and "create lock file." The
solution is to use an atomic create-or-fail action for the lock
file. Exatly what that is will depend on your server, but things to
check on are rename and mkdir.


mkdir is good - if the directory already exists an error will be
raised, this means you don't need to check for it's existence (meaning
a race condition in between checking and attempting to create). If two
"mkdir"s occur simultaneously then it is up to the OS to return an
error to one of them.

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.


Jan 7 '06 #5
"Fuzzyman" <fu******@gmail .com> writes:
Mike Meyer wrote:
"st************ ***@gmail.com" <st************ ***@gmail.com> writes:
> here's a simple-minded suggestion: have the first client create a text
> file on the remote server, and delete it when it is finished updating.
> The second client can check for existence of this file before trying to
> update.

That's an old hack, dating back to at least Unix v6. The problem is
the window between "check for lock file" and "create lock file." The
solution is to use an atomic create-or-fail action for the lock
file. Exactly what that is will depend on your server, but things to
check on are rename and mkdir.

mkdir is good - if the directory already exists an error will be
raised, this means you don't need to check for it's existence (meaning
a race condition in between checking and attempting to create). If two
"mkdir"s occur simultaneously then it is up to the OS to return an
error to one of them.


Except that some os designer (or the ftp server - remember, the OP is
talking to an FTP server to do this!) may decide that mkdir on an
existing directory isn't an error, since the directory exists
afterward. Rename can also work, but again depends on how the os and
FTP server decide to treat the case of renaming to an existing file.
There may be other alternatives as well.

If the OP weren't working through the FTP server, os.open with
os.O_CREAT|os.O _EXCL would do the trick.

<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 7 '06 #6
Preface the update with a rename. If the rename fails,
someone else is updating the file, if it succeeds update
the file and rename back when finished.

Suggestion: ftp is not the best way to handle such a task.
Use a database, XMLRPC or sockets is probably a better
way.

-Larry Bates
mu*******@yahoo .com wrote:
hi all

am updating the same file in ftp, through multiple clients, but am
scared that two clients may open the same file at a time, and try
updating, then the data updated by one data will be lost.
So i have to provide some lock mechanism to that file in ftp, so how
can i lock it, if one client opens it for updating, so that till it
gets relased it cannot be updated by other clients.
Could u please suggest me the simple solutions through the python code.

thanks for the help
Yogi

Jan 10 '06 #7

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

Similar topics

11
5270
by: Mike | last post by:
Looking to find any information on how to properly configure multiple instances of DB2. This is on Win2k db2 ver 7.2. I am basically looking for information on how the multiple instance settings should configured to work, how memory is shared or not, etc. I can not seem to find any good links to this information. Thanks, Mike
9
2761
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and wizards. But, I have found that trying to do something "outside the norm" adds a rather large level of complexity and/or data replication. Background I...
3
6479
by: Matt D | last post by:
I've got two web services that use the same data types and that clients will have to consume. I read the msdn article on sharing types (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/html/service07162002.asp) but I don't want clients to have to add two web references and then manually have to edit the proxy classes....
16
5706
by: Randy Harris | last post by:
I was inspired by the recent discussion of returning multiple recordsets to ADO from a stored procedure. (Amazed is probably more accurate). I asked about how to accomplish same with Oracle and got a nudge in the right direction from Mr. Kreft. I promised to provide details once working, so here it is. The code is shown below. My next...
18
3369
by: Gleep | last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this. The goal I don't want clients to give out their usernames and passwords to friends, since the site relies on subscrption fees. Sessions ID's are matched between the browser and the server. So a users can login with same username and password...
2
7100
by: jasonsgeiger | last post by:
From: "Factor" <jasonsgeiger@gmail.com> Newsgroups: microsoft.public.in.csharp Subject: Multiple Clients, One port Date: Wed, 19 Apr 2006 09:36:02 -0700 I'm been working with sockets for a short while now using a server program a former coworker started. The program listens on a port for incomming connections. When a valid connection is...
1
1066
by: Togacaptain | last post by:
I have a large database driven app that allows multiple web services to be deployed each allowing access to different parts of the database. I want to build a C# service to consume all of the web services exposed and then open them all up through a single generic web service. The reason for this is to allow several different development teams...
6
3968
by: Joseph Geretz | last post by:
I have the following class which I am serializing and passing back and forth between my Web Service application and the client. public class Token : SoapHeader { public string SID; public string UID; public string PWD; }
35
9309
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from 500000 to 3200000 of a file whose size is say 20MB... how do i request a download which starts directly at 500000th byte... thank u cheers
0
7432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7689
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. ...
0
7943
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...
1
7456
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5359
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...
0
5076
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...
0
3490
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...
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.