fix: Update async handling in send_shop_order_invoice_telegram_task for Celery compatibility
This commit is contained in:
@@ -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}'
|
||||
|
||||
Reference in New Issue
Block a user