pygtail icon indicating copy to clipboard operation
pygtail copied to clipboard

Question: How to use pygtail in 'tail -f' use case

Open brifordwylie opened this issue 7 years ago • 2 comments

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 avatar Jan 02 '18 00:01 brifordwylie

@brifordwylie this looks like a good and useful addition, maybe create a PR to the maintainer.

arossert avatar Nov 29 '19 08:11 arossert

@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.

pboushy avatar Feb 25 '22 23:02 pboushy