@@ -197,7 +197,7 @@ def _socket_for_reads(self, session):
197197 def _socket_for_writes (self , session ):
198198 return self .__database .client ._socket_for_writes (session )
199199
200- def _command (self , sock_info , command , slave_ok = False ,
200+ def _command (self , sock_info , command , secondary_ok = False ,
201201 read_preference = None ,
202202 codec_options = None , check = True , allowable_errors = None ,
203203 read_concern = None ,
@@ -211,7 +211,7 @@ def _command(self, sock_info, command, slave_ok=False,
211211 :Parameters:
212212 - `sock_info` - A SocketInfo instance.
213213 - `command` - The command itself, as a SON instance.
214- - `slave_ok `: whether to set the SlaveOkay wire protocol bit.
214+ - `secondary_ok `: whether to set the secondaryOkay wire protocol bit.
215215 - `codec_options` (optional) - An instance of
216216 :class:`~bson.codec_options.CodecOptions`.
217217 - `check`: raise OperationFailure if there are errors
@@ -238,7 +238,7 @@ def _command(self, sock_info, command, slave_ok=False,
238238 return sock_info .command (
239239 self .__database .name ,
240240 command ,
241- slave_ok ,
241+ secondary_ok ,
242242 read_preference or self ._read_preference_for (session ),
243243 codec_options or self .codec_options ,
244244 check ,
@@ -1629,13 +1629,13 @@ def parallel_scan(self, num_cursors, session=None, **kwargs):
16291629 ('numCursors' , num_cursors )])
16301630 cmd .update (kwargs )
16311631
1632- with self ._socket_for_reads (session ) as (sock_info , slave_ok ):
1632+ with self ._socket_for_reads (session ) as (sock_info , secondary_ok ):
16331633 # We call sock_info.command here directly, instead of
16341634 # calling self._command to avoid using an implicit session.
16351635 result = sock_info .command (
16361636 self .__database .name ,
16371637 cmd ,
1638- slave_ok ,
1638+ secondary_ok ,
16391639 self ._read_preference_for (session ),
16401640 self .codec_options ,
16411641 read_concern = self .read_concern ,
@@ -1651,14 +1651,14 @@ def parallel_scan(self, num_cursors, session=None, **kwargs):
16511651
16521652 return cursors
16531653
1654- def _count_cmd (self , session , sock_info , slave_ok , cmd , collation ):
1654+ def _count_cmd (self , session , sock_info , secondary_ok , cmd , collation ):
16551655 """Internal count command helper."""
16561656 # XXX: "ns missing" checks can be removed when we drop support for
16571657 # MongoDB 3.0, see SERVER-17051.
16581658 res = self ._command (
16591659 sock_info ,
16601660 cmd ,
1661- slave_ok ,
1661+ secondary_ok ,
16621662 allowable_errors = ["ns missing" ],
16631663 codec_options = self .__write_response_codec_options ,
16641664 read_concern = self .read_concern ,
@@ -1672,20 +1672,20 @@ def _count(self, cmd, collation=None, session=None):
16721672 """Internal count helper."""
16731673 # XXX: "ns missing" checks can be removed when we drop support for
16741674 # MongoDB 3.0, see SERVER-17051.
1675- def _cmd (session , server , sock_info , slave_ok ):
1675+ def _cmd (session , server , sock_info , secondary_ok ):
16761676 return self ._count_cmd (
1677- session , sock_info , slave_ok , cmd , collation )
1677+ session , sock_info , secondary_ok , cmd , collation )
16781678
16791679 return self .__database .client ._retryable_read (
16801680 _cmd , self ._read_preference_for (session ), session )
16811681
16821682 def _aggregate_one_result (
1683- self , sock_info , slave_ok , cmd , collation , session ):
1683+ self , sock_info , secondary_ok , cmd , collation , session ):
16841684 """Internal helper to run an aggregate that returns a single result."""
16851685 result = self ._command (
16861686 sock_info ,
16871687 cmd ,
1688- slave_ok ,
1688+ secondary_ok ,
16891689 allowable_errors = [26 ], # Ignore NamespaceNotFound.
16901690 codec_options = self .__write_response_codec_options ,
16911691 read_concern = self .read_concern ,
@@ -1719,7 +1719,7 @@ def estimated_document_count(self, **kwargs):
17191719 raise ConfigurationError (
17201720 'estimated_document_count does not support sessions' )
17211721
1722- def _cmd (session , server , sock_info , slave_ok ):
1722+ def _cmd (session , server , sock_info , secondary_ok ):
17231723 if sock_info .max_wire_version >= 12 :
17241724 # MongoDB 4.9+
17251725 pipeline = [
@@ -1731,15 +1731,15 @@ def _cmd(session, server, sock_info, slave_ok):
17311731 ('cursor' , {})])
17321732 cmd .update (kwargs )
17331733 result = self ._aggregate_one_result (
1734- sock_info , slave_ok , cmd , collation = None , session = session )
1734+ sock_info , secondary_ok , cmd , collation = None , session = session )
17351735 if not result :
17361736 return 0
17371737 return int (result ['n' ])
17381738 else :
17391739 # MongoDB < 4.9
17401740 cmd = SON ([('count' , self .__name )])
17411741 cmd .update (kwargs )
1742- return self ._count_cmd (None , sock_info , slave_ok , cmd , None )
1742+ return self ._count_cmd (None , sock_info , secondary_ok , cmd , None )
17431743
17441744 return self .__database .client ._retryable_read (
17451745 _cmd , self .read_preference , None )
@@ -1816,9 +1816,9 @@ def count_documents(self, filter, session=None, **kwargs):
18161816 collation = validate_collation_or_none (kwargs .pop ('collation' , None ))
18171817 cmd .update (kwargs )
18181818
1819- def _cmd (session , server , sock_info , slave_ok ):
1819+ def _cmd (session , server , sock_info , secondary_ok ):
18201820 result = self ._aggregate_one_result (
1821- sock_info , slave_ok , cmd , collation , session )
1821+ sock_info , secondary_ok , cmd , collation , session )
18221822 if not result :
18231823 return 0
18241824 return result ['n' ]
@@ -2294,12 +2294,12 @@ def list_indexes(self, session=None):
22942294 read_pref = ((session and session ._txn_read_preference ())
22952295 or ReadPreference .PRIMARY )
22962296
2297- def _cmd (session , server , sock_info , slave_ok ):
2297+ def _cmd (session , server , sock_info , secondary_ok ):
22982298 cmd = SON ([("listIndexes" , self .__name ), ("cursor" , {})])
22992299 if sock_info .max_wire_version > 2 :
23002300 with self .__database .client ._tmp_session (session , False ) as s :
23012301 try :
2302- cursor = self ._command (sock_info , cmd , slave_ok ,
2302+ cursor = self ._command (sock_info , cmd , secondary_ok ,
23032303 read_pref ,
23042304 codec_options ,
23052305 session = s )["cursor" ]
@@ -2315,7 +2315,7 @@ def _cmd(session, server, sock_info, slave_ok):
23152315 else :
23162316 res = message ._first_batch (
23172317 sock_info , self .__database .name , "system.indexes" ,
2318- {"ns" : self .__full_name }, 0 , slave_ok , codec_options ,
2318+ {"ns" : self .__full_name }, 0 , secondary_ok , codec_options ,
23192319 read_pref , cmd ,
23202320 self .database .client ._event_listeners )
23212321 cursor = res ["cursor" ]
@@ -2676,8 +2676,8 @@ def group(self, key, condition, initial, reduce, finalize=None, **kwargs):
26762676 collation = validate_collation_or_none (kwargs .pop ('collation' , None ))
26772677 cmd .update (kwargs )
26782678
2679- with self ._socket_for_reads (session = None ) as (sock_info , slave_ok ):
2680- return self ._command (sock_info , cmd , slave_ok ,
2679+ with self ._socket_for_reads (session = None ) as (sock_info , secondary_ok ):
2680+ return self ._command (sock_info , cmd , secondary_ok ,
26812681 collation = collation ,
26822682 user_fields = {'retval' : 1 })["retval" ]
26832683
@@ -2780,9 +2780,9 @@ def distinct(self, key, filter=None, session=None, **kwargs):
27802780 kwargs ["query" ] = filter
27812781 collation = validate_collation_or_none (kwargs .pop ('collation' , None ))
27822782 cmd .update (kwargs )
2783- def _cmd (session , server , sock_info , slave_ok ):
2783+ def _cmd (session , server , sock_info , secondary_ok ):
27842784 return self ._command (
2785- sock_info , cmd , slave_ok , read_concern = self .read_concern ,
2785+ sock_info , cmd , secondary_ok , read_concern = self .read_concern ,
27862786 collation = collation , session = session ,
27872787 user_fields = {"values" : 1 })["values" ]
27882788
@@ -2809,7 +2809,7 @@ def _map_reduce(self, map, reduce, out, session, read_pref, **kwargs):
28092809 or read_pref )
28102810
28112811 with self .__database .client ._socket_for_reads (read_pref , session ) as (
2812- sock_info , slave_ok ):
2812+ sock_info , secondary_ok ):
28132813 if (sock_info .max_wire_version >= 4 and
28142814 ('readConcern' not in cmd ) and
28152815 inline ):
@@ -2822,7 +2822,7 @@ def _map_reduce(self, map, reduce, out, session, read_pref, **kwargs):
28222822 write_concern = None
28232823
28242824 return self ._command (
2825- sock_info , cmd , slave_ok , read_pref ,
2825+ sock_info , cmd , secondary_ok , read_pref ,
28262826 read_concern = read_concern ,
28272827 write_concern = write_concern ,
28282828 collation = collation , session = session ,
0 commit comments