MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / test_exhaust_network_error

Method test_exhaust_network_error

test/test_client.py:1561–1582  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1559
1560 @client_context.require_no_mongos
1561 def test_exhaust_network_error(self):
1562 # When doing an exhaust query, the socket stays checked out on success
1563 # but must be checked in on error to avoid semaphore leaks.
1564 client = self.rs_or_single_client(maxPoolSize=1, retryReads=False)
1565 collection = client.pymongo_test.test
1566 pool = get_pool(client)
1567 pool._check_interval_seconds = None # Never check.
1568
1569 # Ensure a socket.
1570 connected(client)
1571
1572 # Cause a network error.
1573 conn = one(pool.conns)
1574 conn.conn.close()
1575 cursor = collection.find(cursor_type=CursorType.EXHAUST)
1576 with self.assertRaises(ConnectionFailure):
1577 next(cursor)
1578
1579 self.assertTrue(conn.closed)
1580
1581 # The semaphore was decremented despite the error.
1582 self.assertEqual(0, pool.requests)
1583
1584 @client_context.require_auth
1585 def test_auth_network_error(self):

Callers

nothing calls this directly

Calls 7

get_poolFunction · 0.90
connectedFunction · 0.90
oneFunction · 0.90
nextFunction · 0.90
rs_or_single_clientMethod · 0.80
closeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected