1

我在 python 2.7 中有一个使用 Mysql 的多线程程序。在我的多线程程序中,线程的常用函数是process_submissions. 在那我使用创建专用连接conn=pool.dedicated_connection()。该函数process_submissions又将此连接传递conn给另一个函数rt_scripts,该函数查询一个表(使用传递给它的连接)并返回到process_submissions。但是我收到以下错误:

   Traceback (most recent call last):
   File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
   self.run()
   File "worker_with_threads3.py", line 20, in run
   process_submission(self.name,self.q)
   File "worker_with_threads3.py", line 47, in process_submission
  cursor.execute(query)
  File "/usr/local/lib/python2.7/dist-packages/DBUtils-1.1-py2.7.egg/DBUtils    /SteadyDB.py", line 552, in tough_method
  result = method(*args, **kwargs) # try to execute
  File "/usr/lib/pymodules/python2.7/mysql/connector/cursor.py", line 314, in execute
res = self.db().protocol.cmd_query(stmt)
  File "/usr/lib/pymodules/python2.7/mysql/connector/protocol.py", line 136, in deco
return func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/mysql/connector/protocol.py", line 479, in cmd_query
return self.handle_cmd_result(self.conn.recv())
  File "/usr/lib/pymodules/python2.7/mysql/connector/protocol.py", line 463, in handle_cmd_result
return self._handle_resultset(buf)[0:2]
  File "/usr/lib/pymodules/python2.7/mysql/connector/protocol.py", line 62, in call
return func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/mysql/connector/protocol.py", line 126, in call
return func(*args,**kwargs)
  File "/usr/lib/pymodules/python2.7/mysql/connector/protocol.py", line 408, in _handle_resultset
fields.append(self._pkt_parse_field(buf))
  File "/usr/lib/pymodules/python2.7/mysql/connector/protocol.py", line 126, in call
return func(*args,**kwargs)
  File "/usr/lib/pymodules/python2.7/mysql/connector/protocol.py", line 289, in _pkt_parse_field
(buf,field['db']) = utils.read_lc_string(buf)
 File "/usr/lib/pymodules/python2.7/mysql/connector/utils.py", line 170, in read_lc_string
if buf[0] == '\xfb':
 InterfaceError: Failed executing the operation; string index out of range

可能是什么原因,像这样传递连接会产生任何问题还是其他原因?

4

0 回答 0