Skip to content

Commit

Permalink
Optionally specify fixed 'now' to fetch()
Browse files Browse the repository at this point in the history
This is used by a corresponding graphite change to
ensure consistent data resolution selection over multiple
calls to fetch()
  • Loading branch information
jcsp committed Dec 10, 2013
1 parent a6c0547 commit 868a8b4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ def info(path):
fh.close()
return None

def fetch(path,fromTime,untilTime=None):
def fetch(path,fromTime,untilTime=None,now=None):
"""fetch(path,fromTime,untilTime=None)
path is a string
Expand All @@ -742,14 +742,15 @@ def fetch(path,fromTime,untilTime=None):
fh = None
try:
fh = open(path,'rb')
return file_fetch(fh, fromTime, untilTime)
return file_fetch(fh, fromTime, untilTime, now)
finally:
if fh:
fh.close()

def file_fetch(fh, fromTime, untilTime):
def file_fetch(fh, fromTime, untilTime, now = None):
header = __readHeader(fh)
now = int( time.time() )
if now is None:
now = int( time.time() )
if untilTime is None:
untilTime = now
fromTime = int(fromTime)
Expand Down

0 comments on commit 868a8b4

Please sign in to comment.