@@ -283,7 +283,7 @@ def as_command(self, sock_info):
283283 cmd = SON ([('explain' , cmd )])
284284 session = self .session
285285 if session :
286- session ._apply_to (cmd , False )
286+ session ._apply_to (cmd , False , self . read_preference )
287287 # Explain does not support readConcern.
288288 if (not explain and session .options .causal_consistency
289289 and session .operation_time is not None
@@ -333,17 +333,19 @@ class _GetMore(object):
333333 """A getmore operation."""
334334
335335 __slots__ = ('db' , 'coll' , 'ntoreturn' , 'cursor_id' , 'max_await_time_ms' ,
336- 'codec_options' , 'session' , 'client' , '__as_command' )
336+ 'codec_options' , 'read_preference' , 'session' , 'client' ,
337+ '__as_command' )
337338
338339 name = 'getMore'
339340
340- def __init__ (self , db , coll , ntoreturn , cursor_id , codec_options , session ,
341- client , max_await_time_ms = None ):
341+ def __init__ (self , db , coll , ntoreturn , cursor_id , codec_options ,
342+ read_preference , session , client , max_await_time_ms = None ):
342343 self .db = db
343344 self .coll = coll
344345 self .ntoreturn = ntoreturn
345346 self .cursor_id = cursor_id
346347 self .codec_options = codec_options
348+ self .read_preference = read_preference
347349 self .session = session
348350 self .client = client
349351 self .max_await_time_ms = max_await_time_ms
@@ -364,7 +366,7 @@ def as_command(self, sock_info):
364366 self .max_await_time_ms )
365367
366368 if self .session :
367- self .session ._apply_to (cmd , False )
369+ self .session ._apply_to (cmd , False , self . read_preference )
368370 sock_info .send_cluster_time (cmd , self .session , self .client )
369371 self .__as_command = cmd , self .db
370372 return self .__as_command
0 commit comments