im试图同时执行4次插入。我现在正在尝试以下操作:
params = [
[1, market_currency_id, add_party1, db],
[1, pair_currency_id, - subs_party1, db],
[2, market_currency_id, -subs_party2, db],
[2, pair_currency_id, add_party2, db]
]
cpu_count = os.cpu_count()
with Pool( cpu_count ) as p:
pu.db
p.map(calculateBalances, params, 1)
def calculateBalances(params):
user_id = params[0]
currency_id = params[1]
amount = params[2]
db = params[3]
_balance = Balance(user_id=user_id, currency_id= currency_id, amount=amount)
db.add(_balance)
但是,出现以下错误:
Can't pickle <class 'sqlalchemy.orm.session.Session'>: it's not the same object as sqlalchemy.orm.session.Session