您好,这是我的代码的一部分:
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语句,并且向控制台最后输出的是fetchone()