Describe the bug
Due to what I believe to be a sync issue between threads, an error is occasionally thrown after stopping commentary because commentary is continuing to attempt to generate after the connection to iRacing has already been severed.
To Reproduce
Steps to reproduce the behavior:
Start commentary on a replay
Stop commentary right as it is in the middle of generating new text
Expected behavior
It should just throw away that commentary line and not throw an exception.
Screenshots/Video
N/A
Additional context
Here is the traceback:
Exception in thread Thread-7 (run):
Traceback (most recent call last):
File "C:\Users\joshj\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
self.run()
File "C:\Users\joshj\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\joshj\OneDrive\Documents\Git\IntelliCaster/src\core\director.py", line 291, in run
self._generate_color_commentary()
File "C:\Users\joshj\OneDrive\Documents\Git\IntelliCaster/src\core\director.py", line 94, in _generate_color_commentary
self.commentary.generate(
File "C:\Users\joshj\OneDrive\Documents\Git\IntelliCaster/src\core\commentary.py", line 71, in generate
text = self.text_generator.generate(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\joshj\OneDrive\Documents\Git\IntelliCaster/src\core\commentary.py", line 233, in generate
new_msg += f"The race is at {track} in {city}, {country}. "
^^^^^
UnboundLocalError: cannot access local variable 'track' where it is not associated with a value
Describe the bug Due to what I believe to be a sync issue between threads, an error is occasionally thrown after stopping commentary because commentary is continuing to attempt to generate after the connection to iRacing has already been severed.
To Reproduce Steps to reproduce the behavior:
Expected behavior It should just throw away that commentary line and not throw an exception.
Screenshots/Video N/A
Additional context Here is the traceback: