Slack Channel - When applying delay it goes in a loop

Hi all,

I had been trying to add a delay between messages send by the bot using the Slack Channel slack.py . When I do that, the bot is looping with the Hello message(this is the first bot utterance in the story).

Here is the content of slack.py

    @staticmethod
    def _get_text_from_slack_buttons(buttons: List[Dict]) -> Text:
        return "".join([b.get("title", "") for b in buttons])

    async def send_text_message(
        self, recipient_id: Text, text: Text, **kwargs: Any
    ) -> None:
        recipient = self.slack_channel or recipient_id

        await asyncio.sleep(2)
        for message_part in text.strip().split("\n\n"):
            await self.client.chat_postMessage(
                channel=recipient, as_user=True, text=message_part, type="mrkdwn",
            )

It seems to be related with the async functions. But I would like to know if someone had some experience working with it.

thanks

@alebeta90 Just to be clear, if you remove the line await asyncio.sleep(2) the bot behaves as usual. If you add this line, you see the replicated message “Hello”. Is that correct?

Hi Tanja,

yes it is correct, the bot loops

any suggestion how can we proceed?

all the best and thanks

@alebeta90 Did you make any progress on this issue? Did you arrive at any potential solution?

@Tanja Any update on this issue?