Skip to content

Commit 47f673b

Browse files
authored
Remove redundant writer.stop call that throws error (#1317)
* Remove redundant writer.stop call that throws error The issue is that the writer has already previously been told to stop. * Remove commented lines and update docstring The _get_new_writer function was previously calling `self._writer.close()`. The `self.writer` function is already being closed in the call stack. Due to `self.writer` and `self._writer` being linked, there was an error that the IO file was closed. The `self._writer.close()` was commented out in a prior commit as a proposal for the change. That comment is now removed. The docstring is updated.
1 parent 97302b9 commit 47f673b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

can/io/logger.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,17 @@ def on_message_received(self, msg: Message) -> None:
208208
self.writer.on_message_received(msg)
209209

210210
def _get_new_writer(self, filename: StringPathLike) -> FileIOMessageWriter:
211-
"""Instantiate a new writer after stopping the old one.
211+
"""Instantiate a new writer.
212+
213+
.. note::
214+
The :attr:`self.writer` should be closed prior to calling this function.
212215
213216
:param filename:
214217
Path-like object that specifies the location and name of the log file.
215218
The log file format is defined by the suffix of `filename`.
216219
:return:
217220
An instance of a writer class.
218221
"""
219-
# Close the old writer first
220-
if self._writer is not None:
221-
self._writer.stop()
222222

223223
logger = Logger(filename, *self.writer_args, **self.writer_kwargs)
224224
if isinstance(logger, FileIOMessageWriter):

0 commit comments

Comments
 (0)