MySQL线程安全问题

MySQL线程安全问题

多线程同用一个数据库连接时,会出现段错误

*** glibc detected *** python: double free or corruption (!prev): 0x0000000002231250 ***
======= Backtrace: =========
/lib64/libc.so.6[0x3a33675dee]
/lib64/libc.so.6[0x3a33678c80]
/usr/lib64/mysql/libmysqlclient.so.20(+0x895f6)[0x7fcdb50e75f6]
/usr/lib64/mysql/libmysqlclient.so.20(+0x78d65)[0x7fcdb50d6d65]
/usr/lib64/mysql/libmysqlclient.so.20(+0x5986b)[0x7fcdb50b786b]
/usr/lib64/mysql/libmysqlclient.so.20(+0x328ea)[0x7fcdb50908ea]
/usr/lib64/mysql/libmysqlclient.so.20(+0x32dbf)[0x7fcdb5090dbf]
/usr/lib64/mysql/libmysqlclient.so.20(+0x338d9)[0x7fcdb50918d9]
/usr/lib64/mysql/libmysqlclient.so.20(mysql_real_query+0x28)[0x7fcdb508f1a8]
............

解决办法
1.最简单的处理方法:
在线程中创建数据库连接

你可能感兴趣的:(python,线程安全)