473,412 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

waiting for file lock?

hi
i need to go into a directory to grab some files and do some
processing.
The thing is, i need to wait till the process that generates the files
in that directory to finish
before i can grab the files. eg if file A is being generated and has
not finished, my python script will not go into the directory.
how can i check that file A has actually finished? thanks

Apr 11 '06 #1
3 2901
In article <11********************@j33g2000cwa.googlegroups.c om>,
s9************@yahoo.com wrote:
i need to go into a directory to grab some files and do some
processing.
The thing is, i need to wait till the process that generates the files
in that directory to finish
before i can grab the files. eg if file A is being generated and has
not finished, my python script will not go into the directory.
how can i check that file A has actually finished?


I wrote a similar system that watches for new files arriving in an
"uploads" directory, whether copied there via FTP or using a GUI desktop
script. My heuristic was to only process files whose last-modified
date/time was at least 5 minutes in the past. My assumption was that it
was unlikely that 5 minutes would go by between more information being
added to a file.
Apr 11 '06 #2
On Tue, 11 Apr 2006 19:07:19 +1200, rumours say that Lawrence D'Oliveiro
<ld*@geek-central.gen.new_zealand> might have written:
In article <11********************@j33g2000cwa.googlegroups.c om>,
s9************@yahoo.com wrote:
i need to go into a directory to grab some files and do some
processing.
The thing is, i need to wait till the process that generates the files
in that directory to finish
before i can grab the files. eg if file A is being generated and has
not finished, my python script will not go into the directory.
how can i check that file A has actually finished?
I wrote a similar system that watches for new files arriving in an
"uploads" directory, whether copied there via FTP or using a GUI desktop
script. My heuristic was to only process files whose last-modified
date/time was at least 5 minutes in the past. My assumption was that it
was unlikely that 5 minutes would go by between more information being
added to a file.


This works (unless there are long network timeouts, when downloading...),
but another idea is to wait for the existence of a zero-byte sentinel file
that is created last, after the transfer (or process, in general) has ended.

This method is the one that has worked best for me.
--
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
Apr 11 '06 #3
s9************@yahoo.com wrote:
hi
i need to go into a directory to grab some files and do some
processing.
The thing is, i need to wait till the process that generates the files
in that directory to finish
before i can grab the files. eg if file A is being generated and has
not finished, my python script will not go into the directory.
how can i check that file A has actually finished? thanks

I don't know if you have control of the program that is writing the
file. If you do, change it so that it writes the files with some
temporary name and renames them when it is done. Since rename is
basically atomic, the file won't show up as a candidate to be
processed until it is actually completed.

Something like:

Process A -> writes files into directory with .tmp extensions.
Process B -> scans directory but never processes anything with
.tmp extensions
Process A -> renames file.tmp to file when it is finished so
that process B picks it up on its next scan.
-Larry Bates
Apr 11 '06 #4

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

Similar topics

6
by: Pekka Niiranen | last post by:
Hi, I have used the following example from win32 extensions: -----SCRIPT STARTS---- import win32file import win32con import win32security import pywintypes
1
by: tracy | last post by:
hi, when i run this sql,i got this error SQL> grant all on raw_ptptn_data to unitem_role; grant all on raw_ptptn_data to unitem_role * ERROR at line 1: ORA-04021: timeout occurred while waiting...
44
by: Charles Law | last post by:
Hi guys. I'm back on the threading gig again. It's the age-old question about waiting for something to happen without wasting time doing it. Take two threads: the main thread and a worker...
5
by: bughunter | last post by:
Hi, Consider this code: ---- Monitor.Pulse(oLock); Monitor.Exit(oLock); ---- If a thread was waiting on oLock then will the current thread
5
by: Ulrich Wisser | last post by:
Hi, after some more debugging I found that my application does on average 3 inserts per second. Which is not very fast, but fast enough for now. But now and then the whole insert proces will be...
1
by: Michael Fuhr | last post by:
For the last couple of hours I've been trying to update my 8.0.0betaX sources with "cvs update" but I keep getting the following: cvs update: Updating . cvs update: Updating ChangeLogs cvs...
16
by: Bruce Wood | last post by:
Maybe it's just late in my day, but I'm reading Jon's article on threading, in particular how to use Monitor.Wait() and Monitor.Pulse(), and there's something that's not sinking in. The code in...
3
by: gautamga | last post by:
Hi anybody, I was getting error like below while compiling package SQL> @pkg_utility.sql CREATE OR REPLACE PACKAGE pkg_utility * ERROR at line 1: ORA-04021: timeout occurred while waiting to...
1
by: gautamga | last post by:
Hi anybody, I was getting error like below while compiling package SQL> @pkg_utility.sql CREATE OR REPLACE PACKAGE pkg_utility * ERROR at line 1: ORA-04021: timeout occurred while waiting to...
4
by: jankhana | last post by:
Hi all, I'm having an application in that i use Sql Compact 3.5 with VS2008. I'm running multiple threads in my application which contacts the compact database and accesses the row. It...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.