Remove blocking call in bot method
This commit is contained in:
parent
b23502ee6a
commit
96d8621d49
@ -1,5 +1,6 @@
|
|||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
import asyncio
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from asgiref.sync import sync_to_async
|
from asgiref.sync import sync_to_async
|
||||||
@ -66,7 +67,7 @@ async def next_vacancy(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||||||
await context.bot.send_message(chat_id=update.effective_chat.id, text=message)
|
await context.bot.send_message(chat_id=update.effective_chat.id, text=message)
|
||||||
return
|
return
|
||||||
|
|
||||||
vacancy = get_next_vacancy(customer_cv)
|
vacancy = await asyncio.to_thread(get_next_vacancy, customer_cv)
|
||||||
if not vacancy:
|
if not vacancy:
|
||||||
message = "Вакансии закончились, возвращайтесь позже!"
|
message = "Вакансии закончились, возвращайтесь позже!"
|
||||||
await context.bot.send_message(chat_id=update.effective_chat.id, text=message)
|
await context.bot.send_message(chat_id=update.effective_chat.id, text=message)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user