Skip to content

Commit

Permalink
fix: Ensure self.tail_thread to be set before add_close_hook
Browse files Browse the repository at this point in the history
The self.tail_thread attrbuite must to be set before adding the
Tail._join_thread to prevent unable to use it on cleanup, otherwise
sometimes will raise AttributeError.

Signed-off-by: Yihuang Yu <[email protected]>
  • Loading branch information
PaulYuuu committed Aug 1, 2024
1 parent 9414aec commit e480480
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion aexpect/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ def __init__(self, command=None, a_id=None, auto_close=False, echo=False,
:param encoding: Override text encoding (by default: autodetect by
locale.getpreferredencoding())
"""
self.tail_thread = None
# Add a reader and a close hook
self._add_reader("tail")
self._add_close_hook(Tail._join_thread)
Expand All @@ -552,7 +553,6 @@ def __init__(self, command=None, a_id=None, auto_close=False, echo=False,
self.output_prefix = output_prefix

# Start the thread in the background
self.tail_thread = None
if self.is_alive():
if termination_func or output_func:
self._start_thread()
Expand Down

0 comments on commit e480480

Please sign in to comment.