Fixed the csv_import
This commit is contained in:
@@ -1161,13 +1161,16 @@ async def _process_csv_import_background(
|
||||
_LOGGER.info("Starting database processing of %s", filename)
|
||||
|
||||
# Create a new session for this background task
|
||||
async with session_maker() as db_session:
|
||||
db_session = await session_maker.create_session()
|
||||
try:
|
||||
importer = CSVImporter(db_session, config)
|
||||
stats = await importer.import_csv_file(str(log_filename), hotel_code, dryrun=False)
|
||||
|
||||
_LOGGER.info(
|
||||
"CSV import complete for %s: %s", filename, stats
|
||||
)
|
||||
finally:
|
||||
await db_session.close()
|
||||
except Exception:
|
||||
_LOGGER.exception(
|
||||
"Error processing CSV import in background for %s", filename
|
||||
|
||||
Reference in New Issue
Block a user