Here are the examples of the python api mockupdb.OpKillCursors taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
3
Example 1
@unittest.skipUnless(sys.version_info >= (3, 4), "Python 3.4 required")
@asyncio_test
def test_fetch_next_delete(self):
client, server = self.client_server(auto_ismaster={'ismaster': True})
cursor = client.test.collection.find()
self.fetch_next(cursor)
request = yield from self.run_thread(server.receives, OpQuery)
request.replies({'_id': 1}, cursor_id=123)
# Decref the cursor and clear from the event loop.
del cursor
yield
yield from self.run_thread(server.receives,
OpKillCursors(cursor_ids=[123]))
0
Example 2
@asyncio_test
def test_cursor_explicit_close(self):
client, server = self.client_server(auto_ismaster={'ismaster': True})
collection = client.test.collection
cursor = collection.find()
future = self.fetch_next(cursor)
self.assertTrue(cursor.alive)
request = yield from self.run_thread(server.receives, OpQuery)
request.replies({'_id': 1}, cursor_id=123)
self.assertTrue((yield from future))
self.assertEqual(123, cursor.cursor_id)
future = self.ensure_future(cursor.close())
# No reply to OP_KILLCURSORS.
yield from self.run_thread(server.receives,
OpKillCursors(cursor_ids=[123]))
yield from future
# Cursor reports it's alive because it has buffered data, even though
# it's killed on the server.
self.assertTrue(cursor.alive)
self.assertEqual({'_id': 1}, cursor.next_object())
self.assertFalse((yield from cursor.fetch_next))
self.assertFalse(cursor.alive)
0
Example 3
Project: motor Source File: test_motor_cursor.py
@gen_test
def test_fetch_next_delete(self):
if sys.version_info < (3, 4):
raise SkipTest("requires Python 3.4")
if 'PyPy' in sys.version:
raise SkipTest('PyPy')
client, server = self.client_server(auto_ismaster={'ismaster': True})
cursor = client.test.collection.find()
# With Tornado, simply accessing fetch_next starts the fetch.
cursor.fetch_next
request = yield self.run_thread(server.receives, OpQuery)
request.replies({'_id': 1}, cursor_id=123)
# Decref'ing the cursor eventually closes it on the server.
del cursor
# Clear Runner's reference. This is Tornado 3 substitute for gen.moment.
yield gen.Task(self.io_loop.add_callback)
yield self.run_thread(server.receives,
OpKillCursors(cursor_ids=[123]))
0
Example 4
@gen_test
def test_cursor_explicit_close(self):
client, server = self.client_server(auto_ismaster={'ismaster': True})
collection = client.test.collection
cursor = collection.find()
# With Tornado, simply accessing fetch_next starts the fetch.
fetch_next = cursor.fetch_next
request = yield self.run_thread(server.receives, OpQuery)
request.replies({'_id': 1}, cursor_id=123)
self.assertTrue((yield fetch_next))
close_future = cursor.close()
yield self.run_thread(server.receives, OpKillCursors(cursor_ids=[123]))
yield close_future
# Cursor reports it's alive because it has buffered data, even though
# it's killed on the server.
self.assertTrue(cursor.alive)
self.assertEqual({'_id': 1}, cursor.next_object())
self.assertFalse((yield cursor.fetch_next))
self.assertFalse(cursor.alive)