PyMySQL卡在fetch_one()上没有错误

时间:2018-12-29 21:17:04

标签: python mysql python-3.x pymysql

您好,这是我的代码的一部分:

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()

之前的打印内容

0 个答案:

没有答案