From e7f5c2ec2a2eff949aa1cd209a16f66622d7782e Mon Sep 17 00:00:00 2001 From: Mike Dirolf Date: Fri, 9 Jan 2009 17:59:14 -0500 Subject: [PATCH] a little more defensive --- mongo.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mongo.py b/mongo.py index a28d67672..82820ef3f 100644 --- a/mongo.py +++ b/mongo.py @@ -75,8 +75,12 @@ class Mongo(object): to_send += data - # TODO be more robust - sent = self.__connection.send(to_send) + total_sent = 0 + while total_sent < len(to_send): + sent = self.__connection.send(to_send[total_sent:]) + if sent == 0: + raise ConnectionException("connection closed") + total_sent += sent def __cmp__(self, other): if isinstance(other, Mongo):