Honesty Rocks! truth rules.

Python Mysqldb Threading

HOME      >>       Programming

rockarolla

I have a small application that spawns several threads which produce output that I insert into the database. The output from one thread is an array and I use

cursor.executemany
.

In the beginning I was always getting the mysql error

lock time exceeded try to restart the transaction

...I managed to resolve this issue - partially it was coming from IDLE editor and the open python shell - seems they were not unlocking the tables while open - so in order for my code to run I use to run it from the shell ...
The next step to handle this was to lock the table before every insert - despite that each thread is using its own mysql connection ...

At this stage the error still occurs - and this results in loss of data and CPU usage....

Any exerience related to python and mysqldb and executemany and threading will be greatly appreciated!