From e87684e06fb41d7f1ae3604cc8570c8048a2dd30 Mon Sep 17 00:00:00 2001 From: Mike Dirolf Date: Tue, 13 Jan 2009 14:56:57 -0500 Subject: [PATCH] kill cursors --- mongo.py | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/mongo.py b/mongo.py index 95b17ab8f..9a6f339a4 100644 --- a/mongo.py +++ b/mongo.py @@ -24,6 +24,7 @@ class InvalidCollection(ValueError): _ZERO = "\x00\x00\x00\x00" _ONE = "\x01\x00\x00\x00" +_MAX_DYING_CURSORS = 20 class Mongo(object): """A connection to a Mongo database. @@ -52,6 +53,7 @@ class Mongo(object): self.__host = host self.__port = port self.__id = 1 + self.__dying_cursors = [] self.__connect() @@ -75,10 +77,8 @@ class Mongo(object): - `operation`: the opcode of the message - `data`: the data to send """ - to_send = "" - # header - to_send += struct.pack(" _MAX_DYING_CURSORS: + message = _ZERO + message += struct.pack(" self.__retrieved: limit = self.__limit - self.__retrieved else: - return 0 + self._die() message = struct.pack("