gpt4 book ai didi

Python:处理 MySQL 连接挂起

转载 作者:行者123 更新时间:2023-11-29 12:56:04 26 4
gpt4 key购买 nike

我正在云计算提供商上同时启动大量 python 作业(大约 320 个作业)。每个 python 作业在启动时都会与 MySQL 服务器建立一些连接。大多数作业的连接都会成功完成,但总有一些作业在连接时挂起。使用 gdb 检查挂起作业的回溯显示了下面的回溯,这似乎表明该进程已挂起等待 MySQL 的响应。

有什么方法可以修复 MySQL 端或 Python 端的挂起吗?

(gdb) bt
#0 0x00007f64612d14cc in recv () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00000000004fb139 in ?? ()
#2 0x0000000000510b4b in ?? ()
#3 0x00000000004cbb0a in PyObject_CallMethodObjArgs ()
#4 0x00007f645e2ee69c in API_recvSocket (sock=0x4f03d00, buffer=0x7f644774b010 "", cbBuffer=cbBuffer@entry=65536) at ./python/io_cpython.c:229
#5 0x00007f645e2ef1c0 in Connection::readSocket (this=this@entry=0x5301720) at ./lib/Connection.cpp:153
#6 0x00007f645e2ef264 in Connection::recvPacket (this=this@entry=0x5301720) at ./lib/Connection.cpp:354
#7 0x00007f645e2efd84 in Connection::connect (this=0x5301720, _host=<optimized out>, _port=<optimized out>, _username=<optimized out>,
_password=<optimized out>, _database=<optimized out>, _autoCommit=0x0, _charset=MCS_utf8_general_ci) at ./lib/Connection.cpp:487
#8 0x00007f645e2ee8aa in UMConnection_Connect (conn=<optimized out>, _host=<optimized out>, _port=<optimized out>, _username=<optimized out>,
_password=<optimized out>, _database=<optimized out>, _autoCommit=0x0, _charset=33) at ./lib/capi.cpp:84
#9 0x00007f645e2ed74e in Connection_connect (self=0x510fcd8, args=<optimized out>) at ./python/umysql.c:860
#10 0x00000000004ac5ce in PyEval_EvalFrameEx ()
#11 0x00000000004b3fd8 in PyEval_EvalCodeEx ()
#12 0x00000000004b4b4c in ?? ()
#13 0x0000000000481cc4 in ?? ()
#14 0x00000000004613b4 in ?? ()
#15 0x0000000000463cc2 in ?? ()
#16 0x00000000004acc66 in PyEval_EvalFrameEx ()
#17 0x00000000004acde0 in PyEval_EvalFrameEx ()
#18 0x00000000004b3fd8 in PyEval_EvalCodeEx ()
#19 0x00000000004acb98 in PyEval_EvalFrameEx ()
#20 0x00000000004b3fd8 in PyEval_EvalCodeEx ()
#21 0x0000000000536723 in ?? ()
#22 0x0000000000446bf2 in PyRun_FileExFlags ()
#23 0x00000000004470ec in PyRun_SimpleFileExFlags ()
#24 0x0000000000447cdc in Py_Main ()
#25 0x00007f64606b6ead in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6`
#26 0x00000000004c7f39 in _start ()

最佳答案

Default number of connections in MySQL is 150 ,您可能想提高一点,看看是否有帮助。

关于Python:处理 MySQL 连接挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24049341/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com