如何使用Python中的Sybase模块设置超时?
有时我会遇到一个问题,对sybase的查询需要很长时间。我想等30秒左右,然后超时。这是我的密码:如何使用Python中的Sybase模块设置超时?,python,sybase,Python,Sybase,有时我会遇到一个问题,对sybase的查询需要很长时间。我想等30秒左右,然后超时。这是我的密码: import Sybase db = Sybase.connect('server','name','pass','database') c = db.cursor() c.execute("select statement that takes a long time") list1 = c.fetchall() print list1 如何重写代码,以便在查询时间超过30秒时生成空列表1
import Sybase
db = Sybase.connect('server','name','pass','database')
c = db.cursor()
c.execute("select statement that takes a long time")
list1 = c.fetchall()
print list1
如何重写代码,以便在查询时间超过30秒时生成空列表1?我看到两种可能性:
def func():
db = Sybase.connect('server','name','pass','database')
c = db.cursor()
c.execute("select statement that takes a long time")
list1 = c.fetchall()
print list1
A = KThread(target=func)
A.start()
time.sleep(30)
if not A.isAlive():
A.kill()
德国劳埃德船级社 据我所知,没有。我会通过给pythonsybase发电子邮件来询问pythonsybase邮件列表-misc@lists.sourceforge.net,但我看到有人问同样的问题(几乎)却没有回答。我没有看到任何文档表明任何方法都有
timeout
参数。