Python 在使用to_sql更新表之后,如何避免永远等待线程-&燃气轮机;如何从等待线程中解脱出来
我试图在MySQL数据库中创建一个表,并用以下内容填充它:Python 在使用to_sql更新表之后,如何避免永远等待线程-&燃气轮机;如何从等待线程中解脱出来,python,mysql,pandas,Python,Mysql,Pandas,我试图在MySQL数据库中创建一个表,并用以下内容填充它: df.to_sql(table_name, con=engine, index=index, if_exists='replace', chunksize=2000) 我在某种程度上成功了,因为我正在创建一个表并上传所有记录。与此同时,脚本仍在工作,直到我手动停止它,并且当我停止时,它总是显示为threading.py/shutdown/join//u wait\u for_tstate\u lock。在
df.to_sql(table_name, con=engine, index=index,
if_exists='replace', chunksize=2000)
我在某种程度上成功了,因为我正在创建一个表并上传所有记录。与此同时,脚本仍在工作,直到我手动停止它,并且当我停止时,它总是显示为threading.py/shutdown/join//u wait\u for_tstate\u lock。在库中,它如下所示:
def _shutdown():
# Obscure: other threads may be waiting to join _main_thread. That's
# dubious, but some code does it. We can't wait for C code to release
# the main thread's tstate_lock - that won't happen until the interpreter
# is nearly dead. So we release it here. Note that just calling _stop()
# isn't enough: other threads may already be waiting on _tstate_lock.
tlock = _main_thread._tstate_lock
# The main thread isn't finished yet, so its thread state lock can't have
# been released.
assert tlock is not None
assert tlock.locked()
tlock.release()
_main_thread._stop()
t = _pickSomeNonDaemonThread()
while t:
t.join()
t = _pickSomeNonDaemonThread()
def _wait_for_tstate_lock(self, block=True, timeout=-1):
# Issue #18808: wait for the thread state to be gone.
# At the end of the thread's life, after all knowledge of the thread
# is removed from C data structures, C code releases our _tstate_lock.
# This method passes its arguments to _tstate_lock.acquire().
# If the lock is acquired, the C code is done, and self._stop() is
# called. That sets ._is_stopped to True, and ._tstate_lock to None.
lock = self._tstate_lock
if lock is None: # already determined that the C code is done
assert self._is_stopped
elif lock.acquire(block, timeout):
lock.release()
self._stop()
我在to_sql(chunksize、method等)中尝试了所有可能的参数——它没有改变任何东西
这是连接代码:
engine = create_engine("mysql+pymysql://{user}:{pw}@{host}:{port}/{db}"
.format(host=_mysql_host, db=reports_db, user=_mysql_username, pw=_mysql_password,
port=tunnel.local_bind_port))