Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - Re: file locking...

 
Thread Tools Search this Thread
Old 03-01-2009, 09:28 AM   #1
Default Re: file locking...


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 of files, and then writes the group
> of files to another dir. I can easily handle this by using a form of
> locking, where I have the processes lock/read a file and only access
> the group of files in the dir based on the open/free status of the
> lockfile.
>
> However, the issue with the approach is that it's somewhat
> synchronous. I'm looking for something that might be more
> asynchronous/parallel, in that I'd like to have multiple processes
> each access a unique group of files from the given dir as fast as
> possible.


I don't see how this is synchronous if you have a lock per file. Perhaps
you've missed something out of your description of your problem.

> So.. Any thoughts/pointers/comments would be greatly appreciated. Any
> pointers to academic research, etc.. would be useful.


I'm not sure you need academic papers here.

One trivial solution to this problem is to have a single process
determine the complete set of files that require processing then fork
off children, each with a different set of files to process.

The parent then just waits for them to finish and does any
post-processing required.

A more concrete problem statement may of course change the solution...

n



Nigel Rantor
  Reply With Quote
Old 03-01-2009, 09:45 AM   #2
koranthala
 
Posts: n/a
Default Re: file locking...
On Mar 1, 2:28*pm, Nigel Rantor <wig...@wiggly.org> 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 of files in a dir. Each
> > process accesses a unique group of files, and then writes the group
> > of files to another dir. I can easily handle this by using a form of
> > locking, where I have the processes lock/read a file and only access
> > the group of files in the dir based on the *open/free status of the
> > lockfile.

>
> > However, the issue with the approach is that it's somewhat
> > synchronous. I'm looking for something that might be more
> > asynchronous/parallel, in that I'd like to have multiple processes
> > each access a unique group of files from the given dir as fast as
> > possible.

>
> I don't see how this is synchronous if you have a lock per file. Perhaps
> you've missed something out of your description of your problem.
>
> > So.. Any thoughts/pointers/comments would be greatly appreciated. Any
> > *pointers to academic research, etc.. would be useful.

>
> I'm not sure you need academic papers here.
>
> One trivial solution to this problem is to have a single process
> determine the complete set of files that require processing then fork
> off children, each with a different set of files to process.
>
> The parent then just waits for them to finish and does any
> post-processing required.
>
> A more concrete problem statement may of course change the solution...
>
> * *n


Using twisted might also be helpful.
Then you can avoid the problems associated with threading too.


koranthala
  Reply With Quote
Old 03-01-2009, 09:59 AM   #3
Nigel Rantor
 
Posts: n/a
Default Re: file locking...
koranthala wrote:
> On Mar 1, 2:28 pm, Nigel Rantor <wig...@wiggly.org> 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 of files in a dir. Each
>>> process accesses a unique group of files, and then writes the group
>>> of files to another dir. I can easily handle this by using a form of
>>> locking, where I have the processes lock/read a file and only access
>>> the group of files in the dir based on the open/free status of the
>>> lockfile.
>>> However, the issue with the approach is that it's somewhat
>>> synchronous. I'm looking for something that might be more
>>> asynchronous/parallel, in that I'd like to have multiple processes
>>> each access a unique group of files from the given dir as fast as
>>> possible.

>> I don't see how this is synchronous if you have a lock per file. Perhaps
>> you've missed something out of your description of your problem.
>>
>>> So.. Any thoughts/pointers/comments would be greatly appreciated. Any
>>> pointers to academic research, etc.. would be useful.

>> I'm not sure you need academic papers here.
>>
>> One trivial solution to this problem is to have a single process
>> determine the complete set of files that require processing then fork
>> off children, each with a different set of files to process.
>>
>> The parent then just waits for them to finish and does any
>> post-processing required.
>>
>> A more concrete problem statement may of course change the solution...
>>
>> n

>
> Using twisted might also be helpful.
> Then you can avoid the problems associated with threading too.


No one mentioned threads.

I can't see how Twisted in this instance isn't like using a sledgehammer
to crack a nut.

n


Nigel Rantor
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Locking locking resolution Frontpage raiderhawk General Help Related Topics 0 01-08-2008 01:42 AM
locking my hard drive tbg General Help Related Topics 1 10-16-2006 11:08 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46