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

half.italian at gmail.com half.italian at gmail.com
Thu Aug 16 05:08:30 CEST 2007


On Aug 15, 2:28 am, "Jorgen Bodde" <jorgen.maill... at gmail.com> wrote:
> 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




More information about the Python-list mailing list