diff --git a/backend/order/tasks.py b/backend/order/tasks.py index ecd2cdb..d50f0ca 100644 --- a/backend/order/tasks.py +++ b/backend/order/tasks.py @@ -161,8 +161,13 @@ def send_shop_order_invoice_telegram_task(shop_order_id, chat_id, bot_token): caption=f'فاکتور سفارش #{shop_order_id}\n{shop_order.shop.shop_name}' ) - # Run async function - asyncio.run(send_invoice()) + # Run async function - create new event loop for Celery context + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + try: + loop.run_until_complete(send_invoice()) + finally: + loop.close() logging.info(f'Successfully sent shop order invoice {shop_order_id} to Telegram chat {chat_id}') return f'Invoice sent successfully to chat {chat_id}'