+ -
当前位置:首页 → 问答吧 → python项目出错,隔一段时间就会异常,各位过来看下怎么解决。。。

python项目出错,隔一段时间就会异常,各位过来看下怎么解决。。。

时间:2011-07-04

来源:互联网

[29 17:21:42]: call_request ERROR 处理异常: Traceback (most recent call last):
  File "/server/pstn_proxy/call_request.py", line 50, in mainProc
  commanderMap[command](channel_no, command, content)
  File "/server/pstn_proxy/sm.py", line 333, in request
  request_person(netx_channel, command, req)
  File "/server/pstn_proxy/sm.py", line 545, in request_person
  subcode, a, b = sm_subcode.get_subcode(req['uid'], '0001', req['phonenum'], 1, 1)
  File "/server/pstn_proxy/sm_subcode.py", line 57, in get_subcode
  cs.execute("SELECT subcode, identifier FROM subcode WHERE pvdcode = '%s' AND phone = '%s'" %(pvdcode, phone))
  File "/usr/local/lib/python2.5/site-packages/DBUtils-0.9.4-py2.5.egg/DBUtils/SteadyDB.py", line 335, in tough_method
  result = method(*args, **kwargs) # try to execute
  File "build/bdist.linux-i686/egg/MySQLdb/cursors.py", line 147, in execute
  charset = db.character_set_name()
InterfaceError: (0, '')

google搜索的结果是:

Try passing the cursor and not the connection -

import MySQLdb

import module_name

connection = MySQLdb.connect(host='localhost', user='user',
passwd='password', db='database')

cursor = connection.cursor()
module = module_name.ClassName(cursor)
但是项目里面的数据库连接部分大概是这样的:
from DBUtils.PersistentDB import PersistentDB
  persist = PersistentDB(creator=dbdriver,**DSN_DB)
 cs = config.persist.connection().cursor(config.persist._creator.cursors.DictCursor)
 在线等结果!!!先谢谢!!!

谷歌的链接 http://objectmix.com/python/17526-re-mysql-interfaceerror.html

作者: youbiyun   发布时间: 2011-07-04

数据库是什么,负载怎么样?
我觉得有可能是连接数过多造成的。

作者: friendmine   发布时间: 2011-07-04