Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

According to GIO Reference Manual Gio.File has a methode copy_async. In Ubuntu 12.04 I'm getting an AttributeError when I try to call this method.

What should I use instead to for asynchronous copying?

I could use Gio.OutputStream.splice_async() but that doesn't give me a progress callback

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The reference manual you are quoting is not for python. I'm aware, that with gobject introspection, no python manual is available anymore (only a tutorial), but this manual does not document the python mapped functionality. A lot of functions from C have not been made accessible from other languages.

One way you might want to go, if you do not require Gio, is simply using python built-in functions?

The concurrent.futures module does things in an async way (backported here). With that you should be able to do something like this:

import concurrent.futures
import shutil

with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
    executor.submit(shutil.copy, "test1.txt", "test1_new.txt").add_done_callback(
      process_result )
    executor.submit(shutil.copy, "test2.txt", "test2_new.txt").add_done_callback(
      process_result)

More about this version here and here.

share|improve this answer
    
I'd prefer GIO asynchronous functions but that doesn't seem to be possible with Python so I'll go with Python libs. concurrent.futures looks nice –  Florian Diesch Feb 15 '13 at 22:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.