-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feature/logger no eof #126
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you envision using this code? The only way I can see right now is on shared filesystem, right? So either the LogReader
runs on the same computer as LogWriter
or they both share the file using something like NFS. Have I missed something?
osgar/test_logger.py
Outdated
|
||
with LogReader(partial) as log: | ||
with self.assertRaises(AssertionError): | ||
dt, channel, data = next(log.read_gen(only_stream_id=1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you feel the need to have a log.read
method. Why not add it? Then log.read_gen
can be implemented using this method. This stuff with next
seems like a hack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There used to be one and it is needed for tests only.
Edit:
There is actually internal read()
function, but maybe I should rename it to _read(self, size)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well if you want to iterate over the file in different places, just create the iterator and repeatedly call next on the same iterator. Don't create new iterator relying on the strange fact that new iterator does not start at the beginning of the file.
i = log.read_gen(only_stream_id=1)
dt, channel, data = next(i)
dt, channel, data = next(i)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see now that is what you did. Thanks. I would also consider changing read_gen
to first seek to the start of the file before returning anything so that this does not ever return.
dt, channel, data = next(log.read_gen(only_stream_id=1)) | ||
|
||
os.remove(partial) | ||
os.remove(filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a side note only partially related to this PR: I think the tests should be using a temporary directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK - I used to analyze failing tests from available intermediate files, but it is no longer needed. Ack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Autocreating a temporary directory for the test will be left to a different time, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please
Well, yes, this is the first step. You read some local file. I was thinking also about URL specifiers like |
Well, I renamed I was going to change the
I would leave it for now (I added test for this strange current behavior), merge it, integrate it with lidarview and then maybe return to it in some later pull request, OK? |
👎 Not a good idea IMHO. Adding the test codifying the existence of the behavior violating the principle of least surprise makes it even worse. If you feel the pressing need to support multiple concurrent iterators over the same log file, the better way to do it is to open the file inside the method |
Well, OK. Maybe we should simply have an iterator ready when |
p.s. I realized why I do not want to use |
OK, now |
I fixed unittests, but also all usages have to be replaced ... |
👍 |
1b5a46b
to
6021e53
Compare
Similar to tail -f ... --follow
6021e53
to
3fe4e36
Compare
Is there a reason for not using |
Well, good point, but I would not handle it is this PR (you maybe wanted to comment #128 ? |
61c620f
to
f4d1321
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
thanks m. |
This PR opens possibility to read log from incomplete file. Note, that there was a bug, that cut data were distributed into system (asserts now).