U
U
unsstrennen2020-08-01 16:32:22
Python
unsstrennen, 2020-08-01 16:32:22

How to make a non-blocking bot response delay?

The task is to provide functions with delayed launch (if the user does not answer within two minutes - delete the chat object) and functions of delayed sending (in order to simulate the printing process). However, these delays must be non-blocking. The current scheme of work: the flask-server provides a connection between the webhook and the functionality of the bot, each dialog is a WABot class, which is created at the first message of the user and deleted when the dialog can be considered closed. Each request to the bot calls the `processing` function in the bot class.
1. How to implement such non-blocking delays in sending messages?
2. How to implement a function call some time after the user has not responded?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2020-08-01
@deliro

If you need exactly synchronously and with a delivery guarantee - cron or Celery. What you described can be done with a cron - write tasks and the deadline for their completion in the database. Once a minute, use a cron script to go through tasks that need to be done and delete/mark them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question