a little more defensive

This commit is contained in:
Mike Dirolf 2009-01-09 17:59:14 -05:00
parent 3495cd482f
commit e7f5c2ec2a

View File

@ -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):