added alive property to Cursor

This commit is contained in:
Mathias Stearn 2010-03-09 16:03:09 -05:00
parent e425a666eb
commit 71f680126d

View File

@ -482,6 +482,17 @@ class Cursor(object):
return len(self.__data)
@property
def alive(self):
"""Does this cursor have the potential to return more data?
This is mostly useful with `tailable cursors
<http://www.mongodb.org/display/DOCS/Tailable+Cursors>`_
since they will stop iterating even though they *may* return more
results in the future.
"""
return bool(len(self.__data) or (not self.__killed))
def __iter__(self):
return self