35
35
from bson .raw_bson import RawBSONDocument
36
36
from bson .son import SON
37
37
from bson .timestamp import Timestamp
38
- from pymongo import ASCENDING , common , helpers , message
38
+ from pymongo import ASCENDING , _csot , common , helpers , message
39
39
from pymongo .aggregation import (
40
40
_CollectionAggregationCommand ,
41
41
_CollectionRawAggregationCommand ,
@@ -217,6 +217,10 @@ def __init__(
217
217
self .__database : Database [_DocumentType ] = database
218
218
self .__name = name
219
219
self .__full_name = "%s.%s" % (self .__database .name , self .__name )
220
+ self .__write_response_codec_options = self .codec_options ._replace (
221
+ unicode_decode_error_handler = "replace" , document_class = dict
222
+ )
223
+ self ._timeout = database .client .options .timeout
220
224
encrypted_fields = kwargs .pop ("encryptedFields" , None )
221
225
if create or kwargs or collation :
222
226
if encrypted_fields :
@@ -230,10 +234,6 @@ def __init__(
230
234
else :
231
235
self .__create (name , kwargs , collation , session )
232
236
233
- self .__write_response_codec_options = self .codec_options ._replace (
234
- unicode_decode_error_handler = "replace" , document_class = dict
235
- )
236
-
237
237
def _socket_for_reads (self , session ):
238
238
return self .__database .client ._socket_for_reads (self ._read_preference_for (session ), session )
239
239
@@ -433,6 +433,7 @@ def with_options(
433
433
read_concern or self .read_concern ,
434
434
)
435
435
436
+ @_csot .apply
436
437
def bulk_write (
437
438
self ,
438
439
requests : Sequence [_WriteOp ],
@@ -631,6 +632,7 @@ def insert_one(
631
632
write_concern .acknowledged ,
632
633
)
633
634
635
+ @_csot .apply
634
636
def insert_many (
635
637
self ,
636
638
documents : Iterable [_DocumentIn ],
@@ -1892,6 +1894,7 @@ def create_indexes(
1892
1894
kwargs ["comment" ] = comment
1893
1895
return self .__create_indexes (indexes , session , ** kwargs )
1894
1896
1897
+ @_csot .apply
1895
1898
def __create_indexes (self , indexes , session , ** kwargs ):
1896
1899
"""Internal createIndexes helper.
1897
1900
@@ -2088,6 +2091,7 @@ def drop_indexes(
2088
2091
kwargs ["comment" ] = comment
2089
2092
self .drop_index ("*" , session = session , ** kwargs )
2090
2093
2094
+ @_csot .apply
2091
2095
def drop_index (
2092
2096
self ,
2093
2097
index_or_name : _IndexKeyHint ,
@@ -2311,6 +2315,7 @@ def options(
2311
2315
2312
2316
return options
2313
2317
2318
+ @_csot .apply
2314
2319
def _aggregate (
2315
2320
self ,
2316
2321
aggregation_command ,
@@ -2618,6 +2623,7 @@ def watch(
2618
2623
full_document_before_change ,
2619
2624
)
2620
2625
2626
+ @_csot .apply
2621
2627
def rename (
2622
2628
self ,
2623
2629
new_name : str ,
0 commit comments