The warning you received is not about the datafeed configuration timeout, but rather the excessive 300s of waiting. You should instead use a scheduler feature of some sort to perform the tasks in your else block so that this on_message_sent def returns immediately. This avoids the situation where the same incoming message gets requeued and you perform duplicate processing. If any member of the help team respond, you can then cancel the scheduled task.
Hi,
I am working on a bot project. The request is using the bot as a reminder. Bot would be added to some chat rooms. If there are some meesges sent to the room but not get any reply (from help team) in 5 mins, the bot would forward the message to another chat room.
What I am done is using the on_message_sent function. Make the bot await for 5 mins and then check if the message should be forwarded.
async def on_message_sent(self, initiator: V4Initiator, event: V4MessageSent):
if (message from help team):
pass
else:
# sleep 5 mins
await asyncio.sleep(300)
#call list_messages api to check if there is any reply within 5 mins
since = int(event.message.timestamp - 1)
allmessages = await self._messages.list_messages(event.message.stream.stream_id, since)
for allmessage in allmessages:
# check if any message from help team: not forward
is_send = False
break
if is_send == True:
await self._messages.send_message("")
With the code above, I got the warning message: root - WARNING - Events processing took longer than 30 seconds, this might lead to events being re-queued in datafeed and re-dispatched. You might want to consider processing the event in a separated asyncio task if needed.
I searched a little bit and found that the datafeed configuration set 30s as default to limit the interval between two attempts. Should I change this to 5mins to avoid this warning? Another question is if this is a proper way to implement the request. If this is not a proper way, could anyone help and explain the logic a little bit?
Thank you.