MCPcopy Create free account
hub / github.com/aws/aws-cli / get_callbacks

Function get_callbacks

awscli/s3transfer/utils.py:101–127  ·  view source on GitHub ↗

Retrieves callbacks from a subscriber :type transfer_future: s3transfer.futures.TransferFuture :param transfer_future: The transfer future the subscriber is associated to. :type callback_type: str :param callback_type: The type of callback to retrieve from the subscriber.

(transfer_future, callback_type)

Source from the content-addressed store, hash-verified

99
100
101def get_callbacks(transfer_future, callback_type):
102 """Retrieves callbacks from a subscriber
103
104 :type transfer_future: s3transfer.futures.TransferFuture
105 :param transfer_future: The transfer future the subscriber is associated
106 to.
107
108 :type callback_type: str
109 :param callback_type: The type of callback to retrieve from the subscriber.
110 Valid types include:
111 * 'queued'
112 * 'progress'
113 * 'done'
114
115 :returns: A list of callbacks for the type specified. All callbacks are
116 preinjected with the transfer future.
117 """
118 callbacks = []
119 for subscriber in transfer_future.meta.call_args.subscribers:
120 callback_name = 'on_' + callback_type
121 if hasattr(subscriber, callback_name):
122 callbacks.append(
123 functools.partial(
124 getattr(subscriber, callback_name), future=transfer_future
125 )
126 )
127 return callbacks
128
129
130def invoke_progress_callbacks(callbacks, bytes_transferred):

Calls

no outgoing calls