473,811 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Synchronous shutil.copyfile ()

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
Jan 30 '07 #1
1 6191
Hugo Ferreira <by****@gmail.c omwrote:
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)?
shutil.copyfile () closes both files before it returns, so I suspect
this is an OS-level bug.

The most likely culprits are buggy network filesystems and buggy
on-access virus scanners.

-M-

Jan 30 '07 #2

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

Similar topics

1
7780
by: bmgz | last post by:
I am have made a simple script that moves all desktop clutter (ie files that are not *.lnk) to a specified folder eg. c:\myhome\mydocs\desktopdebris\2003-12-16 ---------------------------------------------------------------------------- ----------------- import re, os, time, shutil os.chdir(os.environ+os.environ+"\\Desktop") DESKTOP = os.listdir(os.environ+os.environ+"\\Desktop")
8
7639
by: David Nicolson | last post by:
Hi, I wasn't exactly sure where to send this, I don't know if it is a bug in Python or not. This is rare, but it has occurred a few times and seems to be reproducible for those who experience it. Examine this code: This is the output: exceptions.UnicodeDecodeError
11
2318
by: lucidparadox | last post by:
I'm currently new to Python and I haven't been able to find the operator/math function to find the square root or even the x root of a number. I'm rewriting a program that I wrote in BASIC that does the math of a quadratic equation (user puts in a, b, and c values) and tells the user whether it has 1 root, 2 roots, or no real roots and displays the roots if it has real roots. Thanks in advance, Dan
5
18939
by: Ben Sizer | last post by:
I need to copy directories from one place to another, but it needs to overwrite individual files and directories rather than just exiting if a destination file already exists. Previous suggestions have focused on looking at the source for copytree, but it has several places where exceptions can be raised, and the documentation for the shutil functions that copytree is implemented in terms of isn't exactly clear about which exceptions get...
10
3331
by: Robert Dailey | last post by:
Hi, I'm trying to create a Python equivalent of the C++ "ifstream" class, with slight behavior changes. Basically, I want to have a "filestream" object that will allow you to overload the '<<' and '>>' operators to stream out and stream in data, respectively. So far this is what I have: class filestream:
0
2707
by: Ahmed, Shakir | last post by:
Is there any way to copy a file from src to dst if the dst is exclusively open by other users. I am using src = 'c:\mydata\data\*.mdb' dst = 'v:\data\all\*.mdb' shutil.copyfile(src,dst)
2
4147
by: Lance Hoffmeyer | last post by:
Hey all, As always, thanks in advance! I am trying to save a ppt presentation but am having problems regarding spaces and am wondering if I am doing something wrong or whether this is a bug? Also, is there a way around this other than not using spaces in paths or filenames? I can create filesnames without spaces but don't have much control over paths.
1
2760
by: Ahmed, Shakir | last post by:
Need help to copy a personal geodatabase from one location to another: Trying to copy a personal geodatabase from one location to another location where all the users are retrieving data from the second location: 1. I can copy over the updated personal geodatabase to the working location and overwrite it, though the file is opened by ArcGIS users (Local Installation of Arc GIS on the users computers).
4
2606
by: klia | last post by:
hello folks i am trying to tweak the current codes so that later when i call it from the terminal i can provide sourcefile and the destination file rather being fixed in the code. because now i have to specify the sourcefile and the destinationfile in codes and not left to be specified from the terminal. i want to be able to do this. python shutil_copy.py sourcefile, destinationfile import shutil shutil.copyfile(srcfile, dstfile)...
0
9728
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10648
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10389
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10135
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9205
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5554
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3018
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.