Merge branch 'close_connections_ML' into 'dev'

fix connections ML

See merge request spatial/postamates!82
dev
Timofey Malinin 3 years ago
commit 30223c9a18

@ -228,6 +228,7 @@ def raschet():
update_fields_working = update_fields.loc[update_fields.status == 'Working'].reset_index(drop=True)
update_fields_working = update_fields_working.fillna(0)
connection.close()
except Exception as e:
log_to_telegram(f'Ошибка при обновлении полей в базе данных: {e}')
log_to_telegram('Начинается обновление полей в базе')
@ -242,9 +243,10 @@ def raschet():
)
cursor = conn2.cursor()
except:
conn2 = None
log_to_telegram('Не удалось подключиться к базе данных')
# prediction_current
if conn2 is not None:
update_records1 = []
for i in range(0, len(update_fields)):
update_records1.append((int(update_fields.prediction_current[i]), int(update_fields.id[i])))
@ -308,6 +310,7 @@ def raschet():
cursor.execute('ROLLBACK')
psycopg2.extras.execute_batch(cursor, sql_update_query, update_records5)
conn2.commit()
conn2.close()
cache.clear()
log_to_telegram('end raschet')

Loading…
Cancel
Save