Scenario:

I have 2 scripts. One is an ftp program that takes a list of files and downloads them.

The other is a simple program that takes one file and copies it to another directory.

What I want to do:

When the ftp program finishes with one file, I want to run the copy program for that file, but I want the ftp program to move on to the next file while the copy runs.

So this would accomplish the same thing, but not be as effective for what I need to do:

for file in filelist:
[INDENT]download(file)
execfile(copy.py,file)[/INDENT]

Recommended Answers

All 4 Replies

why do they need to be different files, couldn't you just make them definitions in the one file and then just call them when they are needed?

Downloading files takes alot of time, shutil.copy for big files isn't that fast itself, I know the computer can download and copy at the same time (saving some time, which adds up to alot if you're downloading hundreds of files), but if I wrote one big script for the whole thing, the functions wouldn't run simultaneously, they'd run right after each other.

You can launch threads for each new process. Look into the Python subprocess module

I'll look that up thanks!

Also, I just came across shutil.move, seems like it would be faster than shutil.copy, could eliminate the need for 2 different scripts.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.