| 383 | |
| 384 | |
| 385 | class CRTTransferFuture(BaseTransferFuture): |
| 386 | def __init__(self, meta=None, coordinator=None): |
| 387 | """The future associated to a submitted transfer request via CRT S3 client |
| 388 | |
| 389 | :type meta: s3transfer.crt.CRTTransferMeta |
| 390 | :param meta: The metadata associated to the transfer future. |
| 391 | |
| 392 | :type coordinator: s3transfer.crt.CRTTransferCoordinator |
| 393 | :param coordinator: The coordinator associated to the transfer future. |
| 394 | """ |
| 395 | self._meta = meta |
| 396 | if meta is None: |
| 397 | self._meta = CRTTransferMeta() |
| 398 | self._coordinator = coordinator |
| 399 | |
| 400 | @property |
| 401 | def meta(self): |
| 402 | return self._meta |
| 403 | |
| 404 | def done(self): |
| 405 | return self._coordinator.done() |
| 406 | |
| 407 | def result(self, timeout=None): |
| 408 | self._coordinator.result(timeout) |
| 409 | |
| 410 | def cancel(self): |
| 411 | self._coordinator.cancel() |
| 412 | |
| 413 | def set_exception(self, exception): |
| 414 | """Sets the exception on the future.""" |
| 415 | if not self.done(): |
| 416 | raise TransferNotDoneError( |
| 417 | 'set_exception can only be called once the transfer is ' |
| 418 | 'complete.' |
| 419 | ) |
| 420 | self._coordinator.set_exception(exception, override=True) |
| 421 | |
| 422 | |
| 423 | class BaseCRTRequestSerializer: |