|
33 | 33 | _clear_entity_type_registry, |
34 | 34 | _disallow_transactions, |
35 | 35 | ) |
36 | | -from pymongo import ASCENDING, DESCENDING |
| 36 | +from pymongo import ASCENDING, DESCENDING, _csot |
37 | 37 | from pymongo.client_session import ClientSession |
38 | 38 | from pymongo.collection import Collection |
39 | 39 | from pymongo.common import validate_string |
@@ -514,6 +514,7 @@ def __init__( |
514 | 514 | ) |
515 | 515 |
|
516 | 516 | self._chunk_size_bytes = chunk_size_bytes |
| 517 | + self._timeout = db.client.options.timeout |
517 | 518 |
|
518 | 519 | def open_upload_stream( |
519 | 520 | self, |
@@ -631,6 +632,7 @@ def open_upload_stream_with_id( |
631 | 632 |
|
632 | 633 | return GridIn(self._collection, session=session, **opts) |
633 | 634 |
|
| 635 | + @_csot.apply |
634 | 636 | def upload_from_stream( |
635 | 637 | self, |
636 | 638 | filename: str, |
@@ -679,6 +681,7 @@ def upload_from_stream( |
679 | 681 |
|
680 | 682 | return cast(ObjectId, gin._id) |
681 | 683 |
|
| 684 | + @_csot.apply |
682 | 685 | def upload_from_stream_with_id( |
683 | 686 | self, |
684 | 687 | file_id: Any, |
@@ -762,6 +765,7 @@ def open_download_stream( |
762 | 765 | gout._ensure_file() |
763 | 766 | return gout |
764 | 767 |
|
| 768 | + @_csot.apply |
765 | 769 | def download_to_stream( |
766 | 770 | self, file_id: Any, destination: Any, session: Optional[ClientSession] = None |
767 | 771 | ) -> None: |
@@ -795,6 +799,7 @@ def download_to_stream( |
795 | 799 | for chunk in gout: |
796 | 800 | destination.write(chunk) |
797 | 801 |
|
| 802 | + @_csot.apply |
798 | 803 | def delete(self, file_id: Any, session: Optional[ClientSession] = None) -> None: |
799 | 804 | """Given an file_id, delete this stored file's files collection document |
800 | 805 | and associated chunks from a GridFS bucket. |
@@ -926,6 +931,7 @@ def open_download_stream_by_name( |
926 | 931 | except StopIteration: |
927 | 932 | raise NoFile("no version %d for filename %r" % (revision, filename)) |
928 | 933 |
|
| 934 | + @_csot.apply |
929 | 935 | def download_to_stream_by_name( |
930 | 936 | self, |
931 | 937 | filename: str, |
|
0 commit comments