MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / test_process_periodic_tasks

Method test_process_periodic_tasks

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

Source from the content-addressed store, hash-verified

1928
1929 @unittest.skipIf("PyPy" in sys.version, "PYTHON-2938 could fail on PyPy")
1930 def test_process_periodic_tasks(self):
1931 client = self.rs_or_single_client()
1932 coll = client.db.collection
1933 coll.insert_many([{} for _ in range(5)])
1934 cursor = coll.find(batch_size=2)
1935 cursor.next()
1936 c_id = cursor.cursor_id
1937 self.assertIsNotNone(c_id)
1938 client.close()
1939 # Add cursor to kill cursors queue
1940 del cursor
1941 wait_until(
1942 lambda: client._kill_cursors_queue,
1943 "waited for cursor to be added to queue",
1944 )
1945 client._process_periodic_tasks() # This must not raise or print any exceptions
1946 with self.assertRaises(InvalidOperation):
1947 coll.insert_many([{} for _ in range(5)])
1948
1949 def test_service_name_from_kwargs(self):
1950 client = MongoClient(

Callers

nothing calls this directly

Calls 7

wait_untilFunction · 0.90
rs_or_single_clientMethod · 0.80
insert_manyMethod · 0.45
findMethod · 0.45
nextMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected