sickcodemonkey at gmail.com
Tue Jan 30 16:18:40 CET 2007
First off, I am just learning Python, so if there is a more efficient way to
do this, then I am all ears.... (NOTE: The code below is something that I
was messing with to learn threads... So some functionality is not
applicable for your needs..I just wanted to show you a demonstration)
One way that you could get around this, is to use threads. You can lock
your thread and when the lock has been released, you could open it and
ensure your copy has succeeded. Just a thought....
def counter(myId, count):
for i in range(count):
#Copy Your File Here
stdoutmutex = thread.allocate_lock()
exitmutexes = 
for i in range(2):
thread.start_new(counter, (i, 2))
for mutex in exitmutexes:
while not mutex.locked():
#Open Your File Here
On 1/30/07, Hugo Ferreira <bytter at gmail.com> wrote:
> Hi there,
> I have a problem. I'm using calling shutil.copyfile() followed by
> open(). The thing is that most of the times open() is called before
> the actual file is copied. I don't have this problem when doing a
> step-by-step debug, since I give enough time for the OS to copy the
> file, but at run-time, it throws an exception.
> Is there anyway to force a sync copy of the file (make python wait for
> the completion)?
> Thanks in advance!
> Hugo Ferreira
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list