【问题标题】:SSL Error : Python Multiprocessing, PostgresSQL and Psycopg2SSL 错误:Python 多处理、PostgresSQL 和 Psycopg2
【发布时间】:2020-05-22 05:36:45
【问题描述】:

如何调用多个进程?

以下代码适用于 processes = 1。

定义:

def origin_and_url_from_url(url):
    ori_url = url.strip() 
    cursor = connection.cursor()    
    cursor.execute("SELECT DISTINCT url, id FROM origin where url = %s",[ori_url])
    rows = cursor.fetchall()
    cursor.close()
    for a_row in rows:
        with open('TopListwith100CardsWithID.csv','a') as file:
            file.write(str(a_row[1])+ ", ")
            file.write(str(a_row[0]))
            file.write('\n')

呼叫:

with open('SEMethodologies/TopListwith100Cards.csv', 'r') as f:
    reader = csv.reader(f)
    top_list = list(reader)
p = multiprocessing.Pool(1, initializer, ())
logger.info("Pool Started for ids")
results = p.starmap(origin_and_url_from_url, top_list)
print(results)
p.close()

但是如果我通过更改此行 p = multiprocessing.Pool(2, initializer, ()) 来调用两个进程,它会显示此错误 psycopg2.OperationalError: SSL error: decryption failed or bad record Mac

【问题讨论】:

标签: python postgresql multiprocessing psycopg2


【解决方案1】:

我遇到了一个听起来很相似的非常讨厌的错误 - 我的服务会因为这个错误而重新启动

Corruption detected. Cipher functions:OPENSSL_internal:BAD_DECRYPT
routines:OPENSSL_internal:DECRYPTION_FAILED_OR_BAD_RECORD_MAC
Decryption error: TSI_DATA_CORRUPTED

使用 Postgres 数据库在 Google Cloud 中运行 Gunicorn 服务。最终调试了很多多处理配置、Postgres 设置等。

为我修复它的事情是将grpcio python 包冻结在1.29.0,基于this 的答案,该答案说在 GRPC v1.3.x 之后发生解密失败错误。

【讨论】:

    猜你喜欢
    • 2012-01-19
    • 2019-05-06
    • 1970-01-01
    • 2016-11-10
    • 1970-01-01
    • 2016-12-11
    • 2016-08-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多