Describe the bug
We have a service that makes calls to the database and over HTTP via workers. These are managed by kubernetes deployment resources.
These kubernetes pods that contain our workers get killed at random times for certain & specific reasons and we expect it to happen, so all our tasks are idempotent.
Due to a worker getting killed at a specific point we receive a SystemExit and observed an issue where the MySQLResult fails to initialise while a query was being executed and we end up with a UnboundLocalError
To Reproduce
Complete steps to reproduce the behavior:
Hard to reproduce as this is an edge case but the following code should prove that the specific scenario would cause an UnboundLocalError exception to occur. The following code is analogous to the method linked above.
Code:
class BadClass:
def __init__(self) -> None:
self.x = 1
raise SystemExit
def boom():
try:
b = BadClass()
except:
print("Caught exception")
b.x = 2
print("raising")
raise
boom()

Expected behavior
SystemExit should bubble up without causing UnboundLocalError exception to occur
Environment
- OS: Linux
- Server and version: MySQL 5.7.12-log
- PyMySQL version: 1.1.1
Describe the bug
We have a service that makes calls to the database and over HTTP via workers. These are managed by kubernetes deployment resources.
These kubernetes pods that contain our workers get killed at random times for certain & specific reasons and we expect it to happen, so all our tasks are idempotent.
Due to a worker getting killed at a specific point we receive a
SystemExitand observed an issue where theMySQLResultfails to initialise while a query was being executed and we end up with aUnboundLocalErrorTo Reproduce
Complete steps to reproduce the behavior:
Hard to reproduce as this is an edge case but the following code should prove that the specific scenario would cause an
UnboundLocalErrorexception to occur. The following code is analogous to the method linked above.Code:
Expected behavior
SystemExitshould bubble up without causingUnboundLocalErrorexception to occurEnvironment