diff --git a/slack_sdk/socket_mode/aiohttp/__init__.py b/slack_sdk/socket_mode/aiohttp/__init__.py index 69e39dfa..ce6446a1 100644 --- a/slack_sdk/socket_mode/aiohttp/__init__.py +++ b/slack_sdk/socket_mode/aiohttp/__init__.py @@ -95,6 +95,7 @@ def __init__( on_message_listeners: listener functions for on_message on_error_listeners: listener functions for on_error on_close_listeners: listener functions for on_close + loop: an existing asyncio event loop """ self.app_token = app_token self.logger = logger or logging.getLogger(__name__) diff --git a/tests/slack_sdk_async/socket_mode/test_aiohttp.py b/tests/slack_sdk_async/socket_mode/test_aiohttp.py index 797c51c3..44bb2d9d 100644 --- a/tests/slack_sdk_async/socket_mode/test_aiohttp.py +++ b/tests/slack_sdk_async/socket_mode/test_aiohttp.py @@ -1,3 +1,4 @@ +import asyncio import unittest from slack_sdk.socket_mode.aiohttp import SocketModeClient @@ -30,6 +31,19 @@ async def test_init_close(self): finally: await client.close() + @async_test + async def test_init_with_loop(self): + client = SocketModeClient( + app_token="xapp-A111-222-xyz", + web_client=self.web_client, + auto_reconnect_enabled=False, + loop=asyncio.new_event_loop(), + ) + try: + self.assertIsNotNone(client) + finally: + await client.close() + @async_test async def test_issue_new_wss_url(self): client = SocketModeClient(