Closed M0r13n closed 1 year ago
I think there's a new bug here. I'm seeing a situation where it looks like a fixed partial line is being prepended to all subsequent lines. Does the partial variable need to be reset when a complete line is yielded?
Though looking closer at my data now I'm not certain of this, it seems to only be happening for one mmsi so it could also just be a bad transmitter. It apparently fixed itself after I restarted the socket listener so I got suspicious. Will keep monitoring things here...
@jwheare
Good point. I was able to reproduce the issue with a simple test case:
# HAVING a socket
stream = SocketStream(None)
# WHEN receiving a partial line and a complete line afterwards
receiver = MockReceiver([b'Hello\nWor', b'ld\n', b'FooBar\n'])
stream.recv = receiver.recv
# THEN the partial line is not prepended to the next line
result = list(stream.read())
expected = [b'Hello\n', b'World\n', 'FooBar\n']
self.assertEqual(result, expected)
The result should have been [b'Hello\n', b'World\n', 'FooBar\n']
but is [b'Hello\n', b'World\n', b'WorFooBar\n']
. This seems to be exactly the bug that you observed.
Fix is incoming
I merged the fix. A fixed version is available on PyPi: v2.5.4
Thanks! I'm running the fix from #115 via 2.5.4 now and will keep an eye on it.
Relates to https://github.com/M0r13n/pyais/pull/113