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

Method test_pool_removes_dead_socket

test/test_pooling.py:226–246  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

224 self.assertEqual(0, len(cx_pool.conns))
225
226 def test_pool_removes_dead_socket(self):
227 # Test that Pool removes dead socket and the socket doesn't return
228 # itself PYTHON-344
229 cx_pool = self.create_pool(max_pool_size=1, wait_queue_timeout=1)
230 cx_pool._check_interval_seconds = 0 # Always check.
231
232 with cx_pool.checkout() as conn:
233 # Simulate a closed socket without telling the Connection it's
234 # closed.
235 conn.conn.close()
236 self.assertTrue(conn.conn_closed())
237
238 with cx_pool.checkout() as new_connection:
239 self.assertEqual(0, len(cx_pool.conns))
240 self.assertNotEqual(conn, new_connection)
241
242 self.assertEqual(1, len(cx_pool.conns))
243
244 # Semaphore was released.
245 with cx_pool.checkout():
246 pass
247
248 def test_socket_closed(self):
249 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

Callers

nothing calls this directly

Calls 4

create_poolMethod · 0.45
checkoutMethod · 0.45
closeMethod · 0.45
conn_closedMethod · 0.45

Tested by

no test coverage detected