Implemented reporting callbacks.
Both the dependency Tracer class and the Packer class now support a callback object, where the latter is a subclass of the former. For file transfers running in a separate thread, there is a thread-safe wrapper for progress callbacks. This wrapper can be called from any thread, and calls the wrapped callback object from the main thread. This way the callback implementation itself doesn't have to worry about threading issues.
This commit is contained in:
@@ -52,20 +52,14 @@ class S3Packer(Packer):
|
||||
return S3Transferrer(self.client)
|
||||
|
||||
|
||||
class S3Transferrer(threading.Thread, transfer.FileTransferer):
|
||||
class S3Transferrer(transfer.FileTransferer):
|
||||
"""Copies or moves files in source directory order."""
|
||||
|
||||
class AbortUpload(Exception):
|
||||
"""Raised from the upload callback to abort an upload."""
|
||||
|
||||
def __init__(self, botoclient) -> None:
|
||||
# Stupid Thread.__init__ doesn't call super().__init__(),
|
||||
# so it doesn't get chained to transfer.FileTransferer.__init__().
|
||||
# However, I want to have Thread as first subclass so that its
|
||||
# start() and join() methods Just Work™.
|
||||
threading.Thread.__init__(self)
|
||||
transfer.FileTransferer.__init__(self)
|
||||
|
||||
super().__init__()
|
||||
self.client = botoclient
|
||||
|
||||
def run(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user