moving files in a seperate thread (and/or with progress?)

J

Jorgen Bodde

Hi all,

I want to make a small batch copy tool that scans for certain files,
and copies them to a specified directory. Since the files are huge
(AVI / DIVX) typical 300 to 700 Mb, I want to provide the user with
some feedback during the file copy.

Here is my dillemma; When I use shutil.move(..,..) I have to wait
until it's done, there is no feedback, so the GUI basically hangs.
However, shutil.move can be fast because it intelligently renames the
file when it is on the same medium, but slow when it moves to a
different one.
When I use my own implementation of a move mechanism that provides
feedback, I lose that intelligence, and I might slow down the copy
process unneccessarily.

When I move files, feedback is handy to have, but not neccesary so I
thought I can also call shutil.move from a seperate thread so the main
GUI stays responsive. What are my options in aborting a move by
killing the thread or are there other (3rdparty) modules I might use
to get better move or copy performances?

Just opening the file, performing a block copy myself seems like it
will slow down the transfer, but up until now I found no way to move
or copy with progress or abilities to abort the file transfer..

Any ideas?

Regards,
- Jorgen
 
K

kyosohma

Hi all,

I want to make a small batch copy tool that scans for certain files,
and copies them to a specified directory. Since the files are huge
(AVI / DIVX) typical 300 to 700 Mb, I want to provide the user with
some feedback during the file copy.

Here is my dillemma; When I use shutil.move(..,..) I have to wait
until it's done, there is no feedback, so the GUI basically hangs.
However, shutil.move can be fast because it intelligently renames the
file when it is on the same medium, but slow when it moves to a
different one.
When I use my own implementation of a move mechanism that provides
feedback, I lose that intelligence, and I might slow down the copy
process unneccessarily.

When I move files, feedback is handy to have, but not neccesary so I
thought I can also call shutil.move from a seperate thread so the main
GUI stays responsive. What are my options in aborting a move by
killing the thread or are there other (3rdparty) modules I might use
to get better move or copy performances?

Just opening the file, performing a block copy myself seems like it
will slow down the transfer, but up until now I found no way to move
or copy with progress or abilities to abort the file transfer..

Any ideas?

Regards,
- Jorgen

What GUI toolkit are you using? I know that wxPython has a status
widget that could be updated in a thread and it has some good examples
of using threads with long running tasks. I created a program with it
that deletes folders and updates me on its progress.

You can see the wxPython implementation here: http://wiki.wxpython.org/LongRunningTasks

Their widget is called a ProgressDialog. I think there's a custom one
too...

Mike
 
H

half.italian

Hi all,

I want to make a small batch copy tool that scans for certain files,
and copies them to a specified directory. Since the files are huge
(AVI / DIVX) typical 300 to 700 Mb, I want to provide the user with
some feedback during the file copy.

Here is my dillemma; When I use shutil.move(..,..) I have to wait
until it's done, there is no feedback, so the GUI basically hangs.
However, shutil.move can be fast because it intelligently renames the
file when it is on the same medium, but slow when it moves to a
different one.
When I use my own implementation of a move mechanism that provides
feedback, I lose that intelligence, and I might slow down the copy
process unneccessarily.

When I move files, feedback is handy to have, but not neccesary so I
thought I can also call shutil.move from a seperate thread so the main
GUI stays responsive. What are my options in aborting a move by
killing the thread or are there other (3rdparty) modules I might use
to get better move or copy performances?

Just opening the file, performing a block copy myself seems like it
will slow down the transfer, but up until now I found no way to move
or copy with progress or abilities to abort the file transfer..

Any ideas?

Regards,
- Jorgen

The following link helped me to pull it off with Tkinter. A
complicated example, but very well written.

http://uucode.com/texts/pylongopgui/pyguiapp.html

~Sean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top