@@ -197,7 +197,7 @@ def _socket_for_reads(self, session):
197
197
def _socket_for_writes (self , session ):
198
198
return self .__database .client ._socket_for_writes (session )
199
199
200
- def _command (self , sock_info , command , slave_ok = False ,
200
+ def _command (self , sock_info , command , secondary_ok = False ,
201
201
read_preference = None ,
202
202
codec_options = None , check = True , allowable_errors = None ,
203
203
read_concern = None ,
@@ -211,7 +211,7 @@ def _command(self, sock_info, command, slave_ok=False,
211
211
:Parameters:
212
212
- `sock_info` - A SocketInfo instance.
213
213
- `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.
215
215
- `codec_options` (optional) - An instance of
216
216
:class:`~bson.codec_options.CodecOptions`.
217
217
- `check`: raise OperationFailure if there are errors
@@ -238,7 +238,7 @@ def _command(self, sock_info, command, slave_ok=False,
238
238
return sock_info .command (
239
239
self .__database .name ,
240
240
command ,
241
- slave_ok ,
241
+ secondary_ok ,
242
242
read_preference or self ._read_preference_for (session ),
243
243
codec_options or self .codec_options ,
244
244
check ,
@@ -1629,13 +1629,13 @@ def parallel_scan(self, num_cursors, session=None, **kwargs):
1629
1629
('numCursors' , num_cursors )])
1630
1630
cmd .update (kwargs )
1631
1631
1632
- with self ._socket_for_reads (session ) as (sock_info , slave_ok ):
1632
+ with self ._socket_for_reads (session ) as (sock_info , secondary_ok ):
1633
1633
# We call sock_info.command here directly, instead of
1634
1634
# calling self._command to avoid using an implicit session.
1635
1635
result = sock_info .command (
1636
1636
self .__database .name ,
1637
1637
cmd ,
1638
- slave_ok ,
1638
+ secondary_ok ,
1639
1639
self ._read_preference_for (session ),
1640
1640
self .codec_options ,
1641
1641
read_concern = self .read_concern ,
@@ -1651,14 +1651,14 @@ def parallel_scan(self, num_cursors, session=None, **kwargs):
1651
1651
1652
1652
return cursors
1653
1653
1654
- def _count_cmd (self , session , sock_info , slave_ok , cmd , collation ):
1654
+ def _count_cmd (self , session , sock_info , secondary_ok , cmd , collation ):
1655
1655
"""Internal count command helper."""
1656
1656
# XXX: "ns missing" checks can be removed when we drop support for
1657
1657
# MongoDB 3.0, see SERVER-17051.
1658
1658
res = self ._command (
1659
1659
sock_info ,
1660
1660
cmd ,
1661
- slave_ok ,
1661
+ secondary_ok ,
1662
1662
allowable_errors = ["ns missing" ],
1663
1663
codec_options = self .__write_response_codec_options ,
1664
1664
read_concern = self .read_concern ,
@@ -1672,20 +1672,20 @@ def _count(self, cmd, collation=None, session=None):
1672
1672
"""Internal count helper."""
1673
1673
# XXX: "ns missing" checks can be removed when we drop support for
1674
1674
# MongoDB 3.0, see SERVER-17051.
1675
- def _cmd (session , server , sock_info , slave_ok ):
1675
+ def _cmd (session , server , sock_info , secondary_ok ):
1676
1676
return self ._count_cmd (
1677
- session , sock_info , slave_ok , cmd , collation )
1677
+ session , sock_info , secondary_ok , cmd , collation )
1678
1678
1679
1679
return self .__database .client ._retryable_read (
1680
1680
_cmd , self ._read_preference_for (session ), session )
1681
1681
1682
1682
def _aggregate_one_result (
1683
- self , sock_info , slave_ok , cmd , collation , session ):
1683
+ self , sock_info , secondary_ok , cmd , collation , session ):
1684
1684
"""Internal helper to run an aggregate that returns a single result."""
1685
1685
result = self ._command (
1686
1686
sock_info ,
1687
1687
cmd ,
1688
- slave_ok ,
1688
+ secondary_ok ,
1689
1689
allowable_errors = [26 ], # Ignore NamespaceNotFound.
1690
1690
codec_options = self .__write_response_codec_options ,
1691
1691
read_concern = self .read_concern ,
@@ -1719,7 +1719,7 @@ def estimated_document_count(self, **kwargs):
1719
1719
raise ConfigurationError (
1720
1720
'estimated_document_count does not support sessions' )
1721
1721
1722
- def _cmd (session , server , sock_info , slave_ok ):
1722
+ def _cmd (session , server , sock_info , secondary_ok ):
1723
1723
if sock_info .max_wire_version >= 12 :
1724
1724
# MongoDB 4.9+
1725
1725
pipeline = [
@@ -1731,15 +1731,15 @@ def _cmd(session, server, sock_info, slave_ok):
1731
1731
('cursor' , {})])
1732
1732
cmd .update (kwargs )
1733
1733
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 )
1735
1735
if not result :
1736
1736
return 0
1737
1737
return int (result ['n' ])
1738
1738
else :
1739
1739
# MongoDB < 4.9
1740
1740
cmd = SON ([('count' , self .__name )])
1741
1741
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 )
1743
1743
1744
1744
return self .__database .client ._retryable_read (
1745
1745
_cmd , self .read_preference , None )
@@ -1816,9 +1816,9 @@ def count_documents(self, filter, session=None, **kwargs):
1816
1816
collation = validate_collation_or_none (kwargs .pop ('collation' , None ))
1817
1817
cmd .update (kwargs )
1818
1818
1819
- def _cmd (session , server , sock_info , slave_ok ):
1819
+ def _cmd (session , server , sock_info , secondary_ok ):
1820
1820
result = self ._aggregate_one_result (
1821
- sock_info , slave_ok , cmd , collation , session )
1821
+ sock_info , secondary_ok , cmd , collation , session )
1822
1822
if not result :
1823
1823
return 0
1824
1824
return result ['n' ]
@@ -2294,12 +2294,12 @@ def list_indexes(self, session=None):
2294
2294
read_pref = ((session and session ._txn_read_preference ())
2295
2295
or ReadPreference .PRIMARY )
2296
2296
2297
- def _cmd (session , server , sock_info , slave_ok ):
2297
+ def _cmd (session , server , sock_info , secondary_ok ):
2298
2298
cmd = SON ([("listIndexes" , self .__name ), ("cursor" , {})])
2299
2299
if sock_info .max_wire_version > 2 :
2300
2300
with self .__database .client ._tmp_session (session , False ) as s :
2301
2301
try :
2302
- cursor = self ._command (sock_info , cmd , slave_ok ,
2302
+ cursor = self ._command (sock_info , cmd , secondary_ok ,
2303
2303
read_pref ,
2304
2304
codec_options ,
2305
2305
session = s )["cursor" ]
@@ -2315,7 +2315,7 @@ def _cmd(session, server, sock_info, slave_ok):
2315
2315
else :
2316
2316
res = message ._first_batch (
2317
2317
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 ,
2319
2319
read_pref , cmd ,
2320
2320
self .database .client ._event_listeners )
2321
2321
cursor = res ["cursor" ]
@@ -2676,8 +2676,8 @@ def group(self, key, condition, initial, reduce, finalize=None, **kwargs):
2676
2676
collation = validate_collation_or_none (kwargs .pop ('collation' , None ))
2677
2677
cmd .update (kwargs )
2678
2678
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 ,
2681
2681
collation = collation ,
2682
2682
user_fields = {'retval' : 1 })["retval" ]
2683
2683
@@ -2780,9 +2780,9 @@ def distinct(self, key, filter=None, session=None, **kwargs):
2780
2780
kwargs ["query" ] = filter
2781
2781
collation = validate_collation_or_none (kwargs .pop ('collation' , None ))
2782
2782
cmd .update (kwargs )
2783
- def _cmd (session , server , sock_info , slave_ok ):
2783
+ def _cmd (session , server , sock_info , secondary_ok ):
2784
2784
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 ,
2786
2786
collation = collation , session = session ,
2787
2787
user_fields = {"values" : 1 })["values" ]
2788
2788
@@ -2809,7 +2809,7 @@ def _map_reduce(self, map, reduce, out, session, read_pref, **kwargs):
2809
2809
or read_pref )
2810
2810
2811
2811
with self .__database .client ._socket_for_reads (read_pref , session ) as (
2812
- sock_info , slave_ok ):
2812
+ sock_info , secondary_ok ):
2813
2813
if (sock_info .max_wire_version >= 4 and
2814
2814
('readConcern' not in cmd ) and
2815
2815
inline ):
@@ -2822,7 +2822,7 @@ def _map_reduce(self, map, reduce, out, session, read_pref, **kwargs):
2822
2822
write_concern = None
2823
2823
2824
2824
return self ._command (
2825
- sock_info , cmd , slave_ok , read_pref ,
2825
+ sock_info , cmd , secondary_ok , read_pref ,
2826
2826
read_concern = read_concern ,
2827
2827
write_concern = write_concern ,
2828
2828
collation = collation , session = session ,
0 commit comments