[Solved] Got UnboundLocalError: Local Variable referenced before assignment, but it wasn’t
Your findall(‘CRC-START(.*?)CRC-END’, PIDFile.read(), re.S) on line 202 didn’t find anything, PID didn’t get declared, boom, UnboundLocalError. This happens because python interpreter makes a preliminary pass on the code, marking encountered variables as local, but it does not (and cannot) check if code that declares them will actually be executed. Minimal reproducible example of that effect … Read more