Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lines are getting skipped when reading multiple lines within the same millisecond #110

Open
colblitz opened this issue Jun 21, 2023 · 4 comments
Labels

Comments

@colblitz
Copy link

I'm using logstation on a file that I'm printing to from a Python script, and I'm noticing lines being skipped when the Python print call contains newlines (\n). Was able to reproduce with a small example script, the only config change was specifying the file.

with open('test.log', 'a') as f:
    f.write("test line\n")
    f.write("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n")

When watching test.log I get

test line
1
2
4
6
8
10

Screenshot from 2023-06-20 23-42-21
Screenshot from 2023-06-20 23-40-48
Screenshot from 2023-06-20 23-40-30

@jdrews jdrews added the bug label Jun 21, 2023
@jdrews
Copy link
Owner

jdrews commented Jun 21, 2023

Hmm very interesting! Thanks for reporting it. I'll see if I can recreate it.

Is this on Ubuntu? That magenta terminal background looks familiar.

@colblitz
Copy link
Author

yup you got it, ubuntu 22.04

@jdrews
Copy link
Owner

jdrews commented Jul 3, 2023

Quick update: I have been able to recreate this. Surprisingly, if I put in breakpoints at key points in the app, it behaves as expected. This must be a speed/performance problem. I'll keep digging.

I also thought switching to a polling tailing method (e.g. check the file every 500ms for new log lines) instead of a filesystem alert tailing method (e.g. wait for the filesystem to tell me the log file was written to) would fix it. But it didn't.

More to come.

@jdrews
Copy link
Owner

jdrews commented Jul 30, 2023

Seems to be only happening when lines are written out all at the same time or under a millisecond. I still want to fix this, but it shouldn't affect most people.

@jdrews jdrews changed the title Lines are getting skipped when printing from Python Lines are getting skipped when printing multiple lines within the same millisecond Oct 21, 2023
@jdrews jdrews changed the title Lines are getting skipped when printing multiple lines within the same millisecond Lines are getting skipped when reading multiple lines within the same millisecond Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants