gpt4 book ai didi

python - pg.内部错误 : SSL SYSCALL error: EOF detected

转载 作者:行者123 更新时间:2023-11-28 22:52:43 25 4
gpt4 key购买 nike

我有一个使用多处理和访问数据库的 python 代码。它大部分时间都能正常工作,但有时会产生错误。错误原来是

File "/usr/lib/python2.7/multiprocessing/pool.py", line 528, in get
raise self._value
pg.OperationalError: can't rollback

File "/usr/lib/python2.7/multiprocessing/pool.py", line 528, in get
raise self._value
pg.InternalError: SSL SYSCALL error: EOF detected

我用来访问数据库的代码是

def getRecords(db,query):
cur=db.cursor()
cur.execute(query)
types=getTypes(cur.description)
columns=getColumns(cur.description)
rows=cur.fetchall()
cur.close()
try:
db.commit()
except:
db.rollback()

多处理是通过:

po = multiprocessing.Pool()
for an_element in a_list:
for an_object in a_list_of_objects:
results.append(po.apply_async(the_multiprocessed_function, (an_element, an_object)))
po.close()
po.join()
for r in results:
some_function_of(r.get())

我想知道我是否在跨进程共享连接,但是对于每个多进程函数,我创建新连接 (conn = pgdb.connect(...)) 并关闭它 (conn.close())。

然后,我想知道它是否与我提供给我的多处理函数的参数有关,特别是因为它们是我自己定义的类实例,但为什么这会在 pg 中产生错误?

抱歉,如果我的问题不是很清楚,但我不知道在哪里寻找错误。多处理在较小的实例和其他表上工作得很好并且已经过测试。但是当更改查询中的一个表并运行代码以解决更大的问题时,我在某处达到了一些限制。

最佳答案

事实上,这个错误与多处理无关,而只是与 postgresql/pgrouting 中计算最短路径的函数有关。当没有路径连接网络中的两点时,该函数与数据库断开连接,没有任何解释。参见 psycopg2.InterfaceError: connection already closed / pgr_astar有关更多信息。

关于python - pg.内部错误 : SSL SYSCALL error: EOF detected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20201711/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com