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("