0

我的代码如下。

for i in self.parent_job.child_jobs:
  futures.append(executor.submit(invokeRunCommand, i))

for future in concurrent.futures.as_completed(futures):
  print("Future Exception: %s" %future.exception())

executor.shutdown(wait="True")

def invokeRunCommand(self):
    db_connect, db_cur = connect_to_database_pl()
    self.setJobStatus(db_cur, JOB_RUNNING)
    ...

def setJobStatus(self, db_cur, job_status, run_status=RUN_PASSED):
     self.job_status = job_status

     sql = """UPDATE jobs
                 SET job_status=%d
                 WHERE job_id=%d""" \
              %(job_status, self.job_id)
     db_cur.execute(sql)

def connect_to_database_pl(dict_cursor=1):
    database = SQL_DB

    db_users = {
      'employee' : {'user' : 'test',  'password' : 'test123'},
    }
    user = db_users[database]['user']
    password = db_users[database]['password']

    try:
        db_cnxn = MySQLdb.connect (host = SQL_HOST,
                                user = user,
                                passwd = password,
                               db = database)
        if dict_cursor==0:
          db_curs = db_cnxn.cursor()
        else:
          db_curs = db_cnxn.cursor(MySQLdb.cursors.DictCursor)


    except MySQLdb.Error, e:
        print "Error %d: %s" % (e.args[0], e.args[1])
        sys.exit (1)
    return (db_cnxn, db_curs)

我遇到错误“错误 2013:在查询未来异常期间丢失与 MySQL 服务器的连接:1 分段错误”和“错误 2006:MySQL 服务器已消失未来异常:1”

尽管我为每个未来创建了一个连接对象,但我得到了上述错误。

有人可以帮我摆脱这个错误吗?

4

0 回答 0