I have this function trying to print additional ‘.’ every second while it’s copying a big folder (~3GB) from one place to another:
def copy_folder(source, destination):
print 'copying',
while shutil.copytree(src=source, dst=destination):
print '.',
time.sleep(1)
but when I call the function:
source = 'source_folder'
destination = 'destination_folder'
copy_folder(source=source, destination=destination)
it’s copying perfectly fine the whole folder but it does NOT print ‘.’ at all.
Do I need to use threads?
Threading in Python is pretty simple:
Just subclass
threading.Threadand overriderun(). After that, call.start()on an instance of that class and you have a thread.