joshjaysalazar / IntelliCaster

An AI race commentator for iRacing
GNU General Public License v3.0
3 stars 1 forks source link

Missing variable error when stopping commentary #79

Closed joshjaysalazar closed 9 months ago

joshjaysalazar commented 10 months ago

Describe the bug Ocassionally, when stopping commentary, Python will complain about a missing value.

To Reproduce Steps to reproduce the behavior:

  1. Start commentary
  2. Stop it
  3. See the error happen sometimes, but not all the time

Expected behavior Obviously shouldn't throw an error; I think there just needs to be a quick sanity check there to see if data is still flowing from iRacing at that point.

Screenshots/Video N/A

Additional context Here's the traceback:

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
joshjaysalazar commented 9 months ago

Fixed with PR #82