You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a third-party process (don't have control of its behavior) running on Linux / CentOS that writes to a log file on the local system. The folder with that file is samba exported, so other boxes can see it. I mapped that folder on a Win box and am running Python3 (v3.11.1) code to read updates to that file.
Somehow the minute i loop on pygtail, Python is not seeing file being increased anymore. I have also created a test file, just to read that file size, and it works OK. However, when that file test file is running, and I start the pygtail program, the test program also gets stuck. Once the pygtail program is killed, the test program again sees increasing file sizes. Also, when I comment out the for loop on pygtail results (but leave the constructor), the code sees increasing file sizes.
I also have that code running on Linux that samba mapped that folder, and it works like a charm.
Any help would be greatly appreciated.
Here are those programs:
test.py:
from time import sleep
import os
from os import fstat, stat
filename = 'z:\debug.log'
while True:
print ('stat(filename).st_size', stat(filename).st_size)
fh = open (filename, "r", 1)
fh.seek (0, os.SEEK_END)
fh.close ()
sleep (5)
pyg.py
from pygtail import Pygtail
from time import sleep
import os
from os import fstat, stat
filename = 'z:\debug.log'
while True:
print ('stat(filename).st_size', stat(filename).st_size)
py = Pygtail (filename, read_from_end = True, offset_file = 'some_offset.txt')
print ("pygtail pygtail:", py)
for log_line in py:
print ("in the pygtail for loop")
sleep (5)
My test procedures:
Running test.py
1.1. program sees increasing file sizes
Running in parallel pyg.py
2.1. both programs stall at the first size that pygtail grabs
Running in parallel pyg.py with "for log_line ... / print ('in the ..." lines commented out
4.1. both programs see file size increases
Of course, there is no need to run test.py to have pyg.py stall. I added that test program to try to see whether this is a general Python or Windows problem, and better illustrate the process.
I really do not understand how pyg.py can influence test.py other than somehow keeping a lock or something like that on that log file.
The text was updated successfully, but these errors were encountered:
I have a third-party process (don't have control of its behavior) running on Linux / CentOS that writes to a log file on the local system. The folder with that file is samba exported, so other boxes can see it. I mapped that folder on a Win box and am running Python3 (v3.11.1) code to read updates to that file.
Somehow the minute i loop on pygtail, Python is not seeing file being increased anymore. I have also created a test file, just to read that file size, and it works OK. However, when that file test file is running, and I start the pygtail program, the test program also gets stuck. Once the pygtail program is killed, the test program again sees increasing file sizes. Also, when I comment out the for loop on pygtail results (but leave the constructor), the code sees increasing file sizes.
I also have that code running on Linux that samba mapped that folder, and it works like a charm.
Any help would be greatly appreciated.
Here are those programs:
My test procedures:
1.1. program sees increasing file sizes
2.1. both programs stall at the first size that pygtail grabs
3.1. test.py start seeing size increases
4.1. both programs see file size increases
Of course, there is no need to run test.py to have pyg.py stall. I added that test program to try to see whether this is a general Python or Windows problem, and better illustrate the process.
I really do not understand how pyg.py can influence test.py other than somehow keeping a lock or something like that on that log file.
The text was updated successfully, but these errors were encountered: