Skip to content

Stable acknowledgement for incoming requests #84

Closed
@seratch

Description

@seratch

Description

This library runs an event listener before responding to an incoming request from Slack with 200 OK. This means if an event handler takes over 3 seconds, the event request times out and the Slack API server resends the same event up to 3 times. You can easily reproduce this issue with the following code snippet.

import time
@slack_events_adapter.on("app_mention")
def handle_app_mentions(event_data):
    time.sleep(5)
    print("Done!")

As a workaround, developers can use threads to run time-consuming tasks asynchronously. Mixing asyncio may not be a great idea as this is a Flask extension and Flask does not support the mechanism.

import time
from concurrent.futures.thread import ThreadPoolExecutor
executor = ThreadPoolExecutor(5)
@slack_events_adapter.on("app_mention")
def handle_app_mentions(event_data):
    def do_something():
        time.sleep(5)
        print("Done!")
    executor.submit(do_something)
    print("Accepted!")

Improving this library is of course worth considering but in the short run, it's not a priority. Also, not only due to this matter, we recommend using Bolt for Python. The new library supports not only Events API but also all the latest features including interactivity.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugM-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documenteddiscussionM-T: An issue where more input is needed to reach a decisionenhancementM-T: A feature request for new functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions