你好,这是我的部分代码:
db = pymysql.connect(
host = .....,
user = .....,
passwd = .....,
db = .....,
port = .....,
connect_timeout = 5 ,
use_unicode = True,
charset = "utf8",
autocommit = True,
)
c = db.cursor(pymysql.cursors.SSDictCursor)
data = c.execute(my_query) # for example SELECT * FROM PEOPLE
run = True
while run:
### processing in batches of 50
batch = []
for i in range(50):
row = data.fetchone()
if not row:
run = False
break
row = do_something(row)
batch += [row]
do_stuff_that takes_3_minutes(batch)
我的问题是,大约一个小时后,这个代码就会被卡住 data.fetchone()
,但它没有退出或显示任何错误,只是被卡住了。我知道这是因为,我在每条指令之前和之后都添加了print语句,最后一次输出到控制台的是之前的print语句 fetchone()
暂无答案!
目前还没有任何答案,快来回答吧!