Closed jlsalmon closed 11 years ago
Hi WeiJen,
The CopyProcess class is supposed to be used with a corresponding CopyProgressHandler object, to receive updates about the progress of the copy jobs. This was introduced in version 1.1, but unfortunately the documentation for v1.1 has not been uploaded yet. But the progress handler is not compulsory, and indeed your code should not crash if you do not use one. So this is definitely a bug.
To fix your issue for now, you can subclass XRootD.client.utils.CopyProgressHandler like this:
from XRootD.client.utils import CopyProgressHandler
class ProgressHandler(CopyProgressHandler):
"""Utility class to handle progress updates from copy jobs"""
def begin(self, id, total, source, target):
"""Notify when a new job is about to start
:param id: the job number of the copy job
:param total: total number of jobs being processed
:param source: the source url of the current job
:param target: the destination url of the current job
"""
pass
def end(self, status):
"""Notify when the previous job has finished
:param status: status of the job
"""
pass
def update(self, processed, total):
"""Notify about the progress of the current job
:param processed: bytes processed by the current job
:param total: total number of bytes to be processed by the current job
"""
pass
and pass an instance of your progress handler to the copy process like this:
handler = ProgressHandler()
process.add_job(...) # 'process' is your CopyProcess object
process.prepare()
process.run(handler=handler)
You can choose to do something useful with the progress handler if you wish, or just leave the methods empty.
Cheers, Justin
moved from https://savannah.cern.ch/bugs/?101932
Dear Sir, I got the error when I was trying to download files by CopyProcess, do you know how to fix it? My OS: Scientific Linux CERN SLC release 6.4 (Carbon) My Python version:2.6.6 My xrootd version:3.3.2-1
Thanks for your help. Best Regards, W.J. Chang