error when use multithreading and mysqldb

前端 未结 3 566
滥情空心
滥情空心 2020-12-29 00:54

getting error when multithreader program access data .

Exception in thread Thread-2:

ProgrammingError: (2014, \"Commands out of sync; you can\'t run this co         


        
3条回答
  •  暖寄归人
    2020-12-29 01:07

    Thanks to your few informations, I can only guess.

    Probably you access the database from several threads without locking. That's bad.

    You should hold a lock to a threading.Lock() or threading.RLock() while accessing your DB. This prevents several threads from interfering with other thread's actions.

提交回复
热议问题