RE: file locking...

2009-03-03 Thread bruce
esult in a given client never being served the files it's trying to fetch. Potential Soln: 1) Invoke a form of file locking, with each client processes waiting until it gets its lock. 2) Invoke some form of round-robin process, where the master process puts files in different dirs, so each

Re: file locking...

2009-03-02 Thread Thomas Guettler
Hi Bruce, you can do it like Maildir [1] you move (os.rename()) file or directories. Maybe something like this: You have three directories: "todo", "in-process" and "done". A process tries to os.rename from todo to in-process. If it fails, some other process has done it before. If the process is

RE: file locking...

2009-03-02 Thread Lawrence D'Oliveiro
In message , bruce wrote: > my concern about a "gatekeeper" wasn't so much related to performance, as > the possibility of race conditions... Which is what the gatekeeper will prevent. It serializes the granting of locks, and that means no race conditions. -- http://mail.python.org/mailman/li

RE: file locking...

2009-03-02 Thread bruce
python-list-bounces+bedouglas=earthlink@python.org [mailto:python-list-bounces+bedouglas=earthlink@python.org]on Behalf Of Lawrence D'Oliveiro Sent: Monday, March 02, 2009 12:29 AM To: python-list@python.org Subject: RE: file locking... In message , bruce wrote: > using any kind of file lo

RE: file locking...

2009-03-02 Thread Lawrence D'Oliveiro
In message , bruce wrote: > using any kind of file locking process requires that i essentially have a > gatekeeper, allowing a single process to enter, access the files at a > time... The gatekeeper doesn't need to do any more than ensure that any particular filename is on

Re: file locking...

2009-03-02 Thread Lawrence D'Oliveiro
In message , Nigel Rantor wrote: > In other words, why would you rely on a scheme that limits some > processes to certain parts of the data? That could be part of the original requirements, it's not clear from the description so far. -- http://mail.python.org/mailman/listinfo/python-list

Re: file locking...

2009-03-01 Thread Nigel Rantor
zugnush wrote: You could do something like this so that every process will know if the file "belongs" to it without prior coordination, it means a lot of redundant hashing though. In [36]: import md5 In [37]: pool = 11 In [38]: process = 5 In [39]: [f for f in glob.glob('*') if int(md5.md5(

Re: file locking...

2009-03-01 Thread zugnush
You could do something like this so that every process will know if the file "belongs" to it without prior coordination, it means a lot of redundant hashing though. In [36]: import md5 In [37]: pool = 11 In [38]: process = 5 In [39]: [f for f in glob.glob('*') if int(md5.md5(f).hexdigest(),16

Re: file locking...

2009-03-01 Thread Gabriel Genellina
En Sun, 01 Mar 2009 16:11:41 -0200, Nigel Rantor escribió: bruce wrote: i can easily setup a file read/write lock process where a client app gets/locks a file, and then copies/moves the required files from the initial dir to a tmp dir. after the move/copy, the lock is released, and the c

Re: file locking...

2009-03-01 Thread Nigel Rantor
Hi Bruce, Excuse me if I'm a little blunt below. I'm ill grumpy... bruce wrote: hi nigel... using any kind of file locking process requires that i essentially have a gatekeeper, allowing a single process to enter, access the files at a time... I don't beleive this is a nece

RE: file locking...

2009-03-01 Thread bruce
.org]on Behalf Of Gabriel Genellina Sent: Sunday, March 01, 2009 9:50 AM To: python-list@python.org Subject: Re: file locking... En Sun, 01 Mar 2009 15:39:56 -0200, bruce escribió: > the issue that i'm looking at is analogous to a FIFO, where i have lots > of > files being shoved in a dir

Re: file locking...

2009-03-01 Thread Gabriel Genellina
En Sun, 01 Mar 2009 15:39:56 -0200, bruce escribió: the issue that i'm looking at is analogous to a FIFO, where i have lots of files being shoved in a dir from different processes.. on the other end, i want to allow mutiple client processes to access unique groups of these files as fast a

RE: file locking...

2009-03-01 Thread bruce
hi nigel... using any kind of file locking process requires that i essentially have a gatekeeper, allowing a single process to enter, access the files at a time... i can easily setup a file read/write lock process where a client app gets/locks a file, and then copies/moves the required files

RE: file locking...

2009-03-01 Thread bruce
-list-bounces+bedouglas=earthlink@python.org [mailto:python-list-bounces+bedouglas=earthlink@python.org]on Behalf Of MRAB Sent: Sunday, March 01, 2009 8:04 AM To: python-list@python.org Subject: Re: file locking... bruce wrote: > Hi. > > Got a bit of a question/issue that I'

Re: file locking...

2009-03-01 Thread MRAB
bruce wrote: Hi. Got a bit of a question/issue that I'm trying to resolve. I'm asking this of a few groups so bear with me. I'm considering a situation where I have multiple processes running, and each process is going to access a number of files in a dir. Each process accesses a unique group o

Re: file locking...

2009-03-01 Thread Nigel Rantor
koranthala wrote: On Mar 1, 2:28 pm, Nigel Rantor wrote: bruce wrote: Hi. Got a bit of a question/issue that I'm trying to resolve. I'm asking this of a few groups so bear with me. I'm considering a situation where I have multiple processes running, and each process is going to access a number

Re: file locking...

2009-03-01 Thread koranthala
On Mar 1, 2:28 pm, Nigel Rantor wrote: > bruce wrote: > > Hi. > > > Got a bit of a question/issue that I'm trying to resolve. I'm asking > > this of a few groups so bear with me. > > > I'm considering a situation where I have multiple processes running, > > and each process is going to access a nu

Re: file locking...

2009-03-01 Thread Nigel Rantor
bruce wrote: Hi. Got a bit of a question/issue that I'm trying to resolve. I'm asking this of a few groups so bear with me. I'm considering a situation where I have multiple processes running, and each process is going to access a number of files in a dir. Each process accesses a unique group o

file locking...

2009-02-28 Thread bruce
Hi. Got a bit of a question/issue that I'm trying to resolve. I'm asking this of a few groups so bear with me. I'm considering a situation where I have multiple processes running, and each process is going to access a number of files in a dir. Each process accesses a unique group of files, and th

Re: File Locking Forced? Newbie question.

2008-07-15 Thread Sparky
Windows, can I > > have it so that the same file can be open in read mode by more than > > one person or could Window's file locking system get in the way? > > Assuming your question is: can processes A, B & C read > from the same file at the same time, then: Yes.

Re: File Locking Forced? Newbie question.

2008-07-15 Thread Tim Golden
could Window's file locking system get in the way? Assuming your question is: can processes A, B & C read from the same file at the same time, then: Yes. (You can try it out yourself fairly easily if you want. Just open a clutch of interpreter windows and do some open ("abc.t

File Locking Forced? Newbie question.

2008-07-15 Thread Sparky
x27;s file locking system get in the way? Thanks, Sam -- http://mail.python.org/mailman/listinfo/python-list

Re: File locking

2007-03-12 Thread John Nagle
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Dr. Who wrote: > > >>Please let me know if I'm missing something since they seem like >>normal file operations that I would hope Python would abstract away. > > > I don't think of them as "normal" operations. They are "extra" stuff that

Re: File locking

2007-03-12 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Dr. Who wrote: > Please let me know if I'm missing something since they seem like > normal file operations that I would hope Python would abstract away. I don't think of them as "normal" operations. They are "extra" stuff that is not only dependent on the operating system

File locking

2007-03-12 Thread Dr. Who
I'm always disappointed when I find something that Python doesn't handle in a platform independent way. It seems to me that file locking is in that boat. 1. I don't see a way to atomically open a file for writing if and only if it doesn't exist without resorting to os.

Re: Python and file locking - NFS or MySQL?

2005-09-13 Thread Christopher DeMarco
Thanks for the reply; I somehow missed this entire thread in python-list. I'm going to give it a whirl, after digging a bit into the status quo of Linux' NFSv3 implementation. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and file locking - NFS or MySQL?

2005-09-13 Thread Christopher DeMarco
Fredrik Lundh wrote: >os.link(tempfile, lockfile) # atomic! Fredrik, thanks for replying - I monitored python-list but didn't see anything. Gotta get a proper Usenet feed... Are you sure os.link() will be atomic over NFS? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and file locking - NFS or MySQL?

2005-09-02 Thread Fredrik Lundh
Fredrik Lundh wrote: > 5) check the number of links to each file > > n = os.stat(tempfile)[3] > m = os.stat(lockfile)[3] aw, forget that. I shouldn't trust google over my own code. here's the correct algorithm: f = open(tempfile, "w") f.close() n = os.stat(tempfile)[3]

Re: Python and file locking - NFS or MySQL?

2005-09-02 Thread Fredrik Lundh
Christopher DeMarco wrote: > 2. open(2) is atomic on a local FS, I've read discussions that imply > that link(2) is atomic over NFS (is it?), so I can link from local > lockfile to remote target atomically. I don't grok this; open(2) + > link(2) + stat(2) == 3 calls on my fingers. HTH is this s

Re: Python and file locking - NFS or MySQL?

2005-09-02 Thread Jeremy Jones
Christopher DeMarco wrote: >Hi all... > >...I've got a Python script running on a bunch of boxen sharing some >common NFS-exported space. I need (not want :) to lock files for >writing, and I need (not want :) to do it safely (i.e. atomically). >I'm doing this in Linux; NFS4 is available. As I u

Python and file locking - NFS or MySQL?

2005-08-29 Thread Christopher DeMarco
Hi all... ...I've got a Python script running on a bunch of boxen sharing some common NFS-exported space. I need (not want :) to lock files for writing, and I need (not want :) to do it safely (i.e. atomically). I'm doing this in Linux; NFS4 is available. As I understand it, my options are: 1.

Re: File locking is impossible in Windows? SOLUTION

2005-01-02 Thread elbertlev
Sure it will do if one of the processes needs read access only. Scenario when you need shared rw acces with locking: In the file you have "records" say 30 bytes long, 2 processes are reading/writing these records by: lock-read-unlock or lock-write-unlock . Both processes have to open the file with

Re: File locking is impossible in Windows? SOLUTION

2004-12-22 Thread elbertlev
Sure it will do if one of the processes needs read access only. Scenario when you need shared rw acces with locking: In the file you have "records" say 30 bytes long, 2 processes are reading/writing these records by: lock-read-unlock or lock-write-unlock . Both processes have to open the file with

Re: File locking is impossible in Windows? SOLUTION

2004-12-22 Thread Pekka Niiranen
Hi everybody: I played with the class Flock and changed the line win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE,\ to win32con.FILE_SHARE_READ,\ and now I cannot copy the file over which suits me. When file is NOT locked I get: E:\>copy d:\log.txt . Overwrite .\log.txt? (Yes/No/All): y 1

Re: File locking is impossible in Windows?

2004-12-22 Thread elbertlev
I just have written the program in "C", which does the same. It behaves almost the way you described. Tthe copy command gives such diagnostic: The process cannot access the file because another process has locked a portion of the file. 0 file(s) copied. BUT THE FILE IS ACTUALLY OVERWRITTEN.. I'

Re: File locking is impossible in Windows?

2004-12-21 Thread Roger Upole
I get The process cannot access the file because another process has locked a portion of the file. 0 file(s) copied. on both Win2k and WinXP. (Python 2.4, Pywin32 build 203) Are you sure the log.txt you're copying to is actually the right one ? You should at least get a prompt to confir

Re: File locking is impossible in Windows?

2004-12-21 Thread Fredrik Lundh
Pekka Niiranen wrote: > Is there a way around this? How can I stop file being COPIED OVER while > it is being open? you could rename the file before you start updating it, and rename it back when done. -- http://mail.python.org/mailman/listinfo/python-list

File locking is impossible in Windows?

2004-12-21 Thread Pekka Niiranen
Hi, I have used the following example from win32 extensions: -SCRIPT STARTS import win32file import win32con import win32security import pywintypes class Flock: def __init__(self,file): self.file=file secur_att = win32security.SECURITY_ATTRIBUTES()

Re: File locking and logging

2004-12-03 Thread Vinay Sajip
Kamus of Kadizhar <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Thanks to Robert Brewer, I got enough insight into logging to make it work > > Now I have another issue: file locking. Sorry if this is a very basic > question, but I can't fi

File locking and logging

2004-12-02 Thread Kamus of Kadizhar
Thanks to Robert Brewer, I got enough insight into logging to make it work Now I have another issue: file locking. Sorry if this is a very basic question, but I can't find a handy reference anywhere that mentions this. When a logger opens a log file for append, is it automatically l