Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
How to let on_message_sent function await 5 mins and then send message


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):
        # 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
				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.

Posted 11 months ago
Edited 11 months ago
Votes Newest


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.

Posted 11 months ago
Yong Sheng Tan
39 × 2 Administrator
1 Answer
11 months ago
11 months ago