Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve synchronous function running in the Async Slack Socket Mode #350

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/348.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Resolve the issue of a synchronous function running in the async sockets.
smk4664 marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 4 additions & 3 deletions nautobot_chatops/sockets/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import shlex

from asgiref.sync import sync_to_async
from django.conf import settings
from slack_sdk.socket_mode.aiohttp import SocketModeClient
from slack_sdk.socket_mode.request import SocketModeRequest
Expand Down Expand Up @@ -71,7 +72,7 @@ async def process_slash_command(client, req):
client.logger.error("%s", err)
return

registry = get_commands_registry()
registry = await sync_to_async(get_commands_registry)()

if command not in registry:
SlackDispatcher(context).send_markdown(commands_help(prefix=SLASH_PREFIX))
Expand Down Expand Up @@ -210,7 +211,7 @@ async def process_interactive(client, req):

client.logger.info(f"command: {command}, subcommand: {subcommand}, params: {params}")

registry = get_commands_registry()
registry = await sync_to_async(get_commands_registry)()

if command not in registry:
SlackDispatcher(context).send_markdown(commands_help(prefix=SLASH_PREFIX))
Expand Down Expand Up @@ -241,7 +242,7 @@ async def process_mention(client, req):
client.logger.error("%s", err)
return

registry = get_commands_registry()
registry = await sync_to_async(get_commands_registry)()

if command not in registry:
SlackDispatcher(context).send_markdown(commands_help(prefix=SLASH_PREFIX))
Expand Down