pygtail
pygtail copied to clipboard
Question: How to use pygtail in 'tail -f' use case
I'm sure it's easy but I'm somehow just not getting it.
I'm using this bit of code around pygtail but I want to sanity check with folks in case I'm doing something silly.
def next_with_tail(self):
"""This is a wrapper around pygtail next so we dynamically tail the file"""
while True:
try:
return self.pygtail.next()
except StopIteration:
if self.dynamic_tail:
time.sleep(.5)
else:
raise
This code seems to work just fine but again there might be like 'Oh.. flip on option X' or just do foo...
@brifordwylie this looks like a good and useful addition, maybe create a PR to the maintainer.
@brifordwylie do you have more info on what you did with this? I'm needing to follow a specific file that rotates by renaming .0 to .1. I need to finish reading all the lines of .1, and then move on to the beginning of .0 and I think what you were doing is kinda that.