Race condition when logfile is rotated while pygtail is running
There is at least one race condition when creating a pygtail instance at the same time a logfile is rotated, which can lead to impossible offset files being created. A test-case for this can be found in this commit: https://github.com/bgreenlee/pygtail/commit/98d3d50986cf4b2c9ec5df8b3ec97e8273a1ea72
This is caused by __init__ determining the name of the logfile referenced by offset_file_inode, but the file only being opened once the first line is read. If the file was rotated in between, _filehandle will open the newer logfile, but try to seek to the old offset, which in most cases is after the end of the file, so the read will fail. However when writing the offset, tell() is used, which will return the offset that was seeked to, not the length of the new file -> We end up with the inode of the new file, but the old offset being written to the offset file.