Good time of day.
There is a multithreaded application that uses multiple threads to peewee. Shortly after launch, crashes with the following exception:
peewee.OperationalError: (2006, "MySQL server has gone away (BrokenPipeError(32, 'Broken pipe'))")
In fact, this is, of course, falls off PyMySQL, which uses the kernel peewee. Based on experience, to work with PyMySQL helped threading.Lock:
from threading import Lock
database_locker = Lock()
pass #work with DB
That's only if peewee is somehow not working.
What do you think? Should help threading.Lock, and whether there are other approaches to solving the problem?