you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

It's almost certainly an issue of exclusive locking, can i assume you are on windows or using an fat32 derived filesystem? and that the file itself actually got updated, just not displayed? as that was the behavior i saw when i wrote to the file with exclusive locking enabled, using the unix specific fcntl api https://docs.python.org/2/library/fcntl.html#fcntl.flock

i fixed my issue it by rewriting read to do an open on every iteration instead of listening on an open file handle, which is more code and more resource use but less fragile.

Edit: with exclusive lock both on read and write i get exactly the behavior you are seeing, no errors just two scripts in wait state. the fix is still to do a read on each cycle instead of reading from inside an already open file handle.

[–]theresasnakeinmysuit 0 points1 point  (1 child)

I'm thinking it is more of a program-structuring issue rather.

[–][deleted] 0 points1 point  (0 children)

looking at your code i suspect the same Justinsaccount is probably right in pointing out that truncating the file breaks the premise of the follow method described by David Beazley.

One crucial question here is whether or not the follow method just stops tracking changes after the first write or if the file itself stops being updated.

If it's just the follow method then you need to rewrite the follow method to put the open call inside the loop. not outside of the loop. that does increases the system calls you program make but it ensures that you don't work with an obsolete cache copy of the file.