UnboundLocalError in connect_to() function
Bug
When the port number is less than 0, the function connect_to
an error using an unbound variable error
print
Output
UnboundLocalError: cannot access local variable 'error' where it is not associated with a value`
Fix
Replace with last_error
variable
if port < 0:
if last_error is not None:
print(f"Error reading pid file {last_error}")