Skip to content

Commit

Permalink
version 1.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Sep 30, 2022
1 parent ad7117b commit 0ca2874
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 120 deletions.
68 changes: 38 additions & 30 deletions docs/api-docs/slack_bolt/app/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -1234,21 +1234,25 @@ <h1 class="title">Module <code>slack_bolt.app.app</code></h1>
def _init_context(self, req: BoltRequest):
req.context[&#34;logger&#34;] = get_bolt_app_logger(app_name=self.name, base_logger=self._base_logger)
req.context[&#34;token&#34;] = self._token
if self._token is not None:
# This WebClient instance can be safely singleton
req.context[&#34;client&#34;] = self._client
else:
# Set a new dedicated instance for this request
client_per_request: WebClient = WebClient(
token=None, # the token will be set later
base_url=self._client.base_url,
timeout=self._client.timeout,
ssl=self._client.ssl,
proxy=self._client.proxy,
headers=self._client.headers,
team_id=req.context.team_id,
)
req.context[&#34;client&#34;] = client_per_request
# Prior to version 1.15, when the token is static, self._client was passed to `req.context`.
# The intention was to avoid creating a new instance per request
# in the interest of runtime performance/memory footprint optimization.
# However, developers may want to replace the token held by req.context.client in some situations.
# In this case, this behavior can result in thread-unsafe data modification on `self._client`.
# (`self._client` a.k.a. `app.client` is a singleton object per an App instance)
# Thus, we&#39;ve changed the behavior to create a new instance per request regardless of token argument
# in the App initialization starting v1.15.
# The overhead brought by this change is slight so that we believe that it is ignorable in any cases.
client_per_request: WebClient = WebClient(
token=self._token, # this can be None, and it can be set later on
base_url=self._client.base_url,
timeout=self._client.timeout,
ssl=self._client.ssl,
proxy=self._client.proxy,
headers=self._client.headers,
team_id=req.context.team_id,
)
req.context[&#34;client&#34;] = client_per_request

@staticmethod
def _to_listener_functions(
Expand Down Expand Up @@ -2653,21 +2657,25 @@ <h2 id="args">Args</h2>
def _init_context(self, req: BoltRequest):
req.context[&#34;logger&#34;] = get_bolt_app_logger(app_name=self.name, base_logger=self._base_logger)
req.context[&#34;token&#34;] = self._token
if self._token is not None:
# This WebClient instance can be safely singleton
req.context[&#34;client&#34;] = self._client
else:
# Set a new dedicated instance for this request
client_per_request: WebClient = WebClient(
token=None, # the token will be set later
base_url=self._client.base_url,
timeout=self._client.timeout,
ssl=self._client.ssl,
proxy=self._client.proxy,
headers=self._client.headers,
team_id=req.context.team_id,
)
req.context[&#34;client&#34;] = client_per_request
# Prior to version 1.15, when the token is static, self._client was passed to `req.context`.
# The intention was to avoid creating a new instance per request
# in the interest of runtime performance/memory footprint optimization.
# However, developers may want to replace the token held by req.context.client in some situations.
# In this case, this behavior can result in thread-unsafe data modification on `self._client`.
# (`self._client` a.k.a. `app.client` is a singleton object per an App instance)
# Thus, we&#39;ve changed the behavior to create a new instance per request regardless of token argument
# in the App initialization starting v1.15.
# The overhead brought by this change is slight so that we believe that it is ignorable in any cases.
client_per_request: WebClient = WebClient(
token=self._token, # this can be None, and it can be set later on
base_url=self._client.base_url,
timeout=self._client.timeout,
ssl=self._client.ssl,
proxy=self._client.proxy,
headers=self._client.headers,
team_id=req.context.team_id,
)
req.context[&#34;client&#34;] = client_per_request

@staticmethod
def _to_listener_functions(
Expand Down
76 changes: 42 additions & 34 deletions docs/api-docs/slack_bolt/app/async_app.html
Original file line number Diff line number Diff line change
Expand Up @@ -1268,23 +1268,27 @@ <h1 class="title">Module <code>slack_bolt.app.async_app</code></h1>
def _init_context(self, req: AsyncBoltRequest):
req.context[&#34;logger&#34;] = get_bolt_app_logger(app_name=self.name, base_logger=self._base_logger)
req.context[&#34;token&#34;] = self._token
if self._token is not None:
# This AsyncWebClient instance can be safely singleton
req.context[&#34;client&#34;] = self._async_client
else:
# Set a new dedicated instance for this request
client_per_request: AsyncWebClient = AsyncWebClient(
token=None, # the token will be set later
base_url=self._async_client.base_url,
timeout=self._async_client.timeout,
ssl=self._async_client.ssl,
proxy=self._async_client.proxy,
session=self._async_client.session,
trust_env_in_session=self._async_client.trust_env_in_session,
headers=self._async_client.headers,
team_id=req.context.team_id,
)
req.context[&#34;client&#34;] = client_per_request
# Prior to version 1.15, when the token is static, self._client was passed to `req.context`.
# The intention was to avoid creating a new instance per request
# in the interest of runtime performance/memory footprint optimization.
# However, developers may want to replace the token held by req.context.client in some situations.
# In this case, this behavior can result in thread-unsafe data modification on `self._client`.
# (`self._client` a.k.a. `app.client` is a singleton object per an App instance)
# Thus, we&#39;ve changed the behavior to create a new instance per request regardless of token argument
# in the App initialization starting v1.15.
# The overhead brought by this change is slight so that we believe that it is ignorable in any cases.
client_per_request: AsyncWebClient = AsyncWebClient(
token=self._token, # this can be None, and it can be set later on
base_url=self._async_client.base_url,
timeout=self._async_client.timeout,
ssl=self._async_client.ssl,
proxy=self._async_client.proxy,
session=self._async_client.session,
trust_env_in_session=self._async_client.trust_env_in_session,
headers=self._async_client.headers,
team_id=req.context.team_id,
)
req.context[&#34;client&#34;] = client_per_request

@staticmethod
def _to_listener_functions(
Expand Down Expand Up @@ -2583,23 +2587,27 @@ <h2 id="args">Args</h2>
def _init_context(self, req: AsyncBoltRequest):
req.context[&#34;logger&#34;] = get_bolt_app_logger(app_name=self.name, base_logger=self._base_logger)
req.context[&#34;token&#34;] = self._token
if self._token is not None:
# This AsyncWebClient instance can be safely singleton
req.context[&#34;client&#34;] = self._async_client
else:
# Set a new dedicated instance for this request
client_per_request: AsyncWebClient = AsyncWebClient(
token=None, # the token will be set later
base_url=self._async_client.base_url,
timeout=self._async_client.timeout,
ssl=self._async_client.ssl,
proxy=self._async_client.proxy,
session=self._async_client.session,
trust_env_in_session=self._async_client.trust_env_in_session,
headers=self._async_client.headers,
team_id=req.context.team_id,
)
req.context[&#34;client&#34;] = client_per_request
# Prior to version 1.15, when the token is static, self._client was passed to `req.context`.
# The intention was to avoid creating a new instance per request
# in the interest of runtime performance/memory footprint optimization.
# However, developers may want to replace the token held by req.context.client in some situations.
# In this case, this behavior can result in thread-unsafe data modification on `self._client`.
# (`self._client` a.k.a. `app.client` is a singleton object per an App instance)
# Thus, we&#39;ve changed the behavior to create a new instance per request regardless of token argument
# in the App initialization starting v1.15.
# The overhead brought by this change is slight so that we believe that it is ignorable in any cases.
client_per_request: AsyncWebClient = AsyncWebClient(
token=self._token, # this can be None, and it can be set later on
base_url=self._async_client.base_url,
timeout=self._async_client.timeout,
ssl=self._async_client.ssl,
proxy=self._async_client.proxy,
session=self._async_client.session,
trust_env_in_session=self._async_client.trust_env_in_session,
headers=self._async_client.headers,
team_id=req.context.team_id,
)
req.context[&#34;client&#34;] = client_per_request

@staticmethod
def _to_listener_functions(
Expand Down
34 changes: 19 additions & 15 deletions docs/api-docs/slack_bolt/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1281,21 +1281,25 @@ <h2 id="args">Args</h2>
def _init_context(self, req: BoltRequest):
req.context[&#34;logger&#34;] = get_bolt_app_logger(app_name=self.name, base_logger=self._base_logger)
req.context[&#34;token&#34;] = self._token
if self._token is not None:
# This WebClient instance can be safely singleton
req.context[&#34;client&#34;] = self._client
else:
# Set a new dedicated instance for this request
client_per_request: WebClient = WebClient(
token=None, # the token will be set later
base_url=self._client.base_url,
timeout=self._client.timeout,
ssl=self._client.ssl,
proxy=self._client.proxy,
headers=self._client.headers,
team_id=req.context.team_id,
)
req.context[&#34;client&#34;] = client_per_request
# Prior to version 1.15, when the token is static, self._client was passed to `req.context`.
# The intention was to avoid creating a new instance per request
# in the interest of runtime performance/memory footprint optimization.
# However, developers may want to replace the token held by req.context.client in some situations.
# In this case, this behavior can result in thread-unsafe data modification on `self._client`.
# (`self._client` a.k.a. `app.client` is a singleton object per an App instance)
# Thus, we&#39;ve changed the behavior to create a new instance per request regardless of token argument
# in the App initialization starting v1.15.
# The overhead brought by this change is slight so that we believe that it is ignorable in any cases.
client_per_request: WebClient = WebClient(
token=self._token, # this can be None, and it can be set later on
base_url=self._client.base_url,
timeout=self._client.timeout,
ssl=self._client.ssl,
proxy=self._client.proxy,
headers=self._client.headers,
team_id=req.context.team_id,
)
req.context[&#34;client&#34;] = client_per_request

@staticmethod
def _to_listener_functions(
Expand Down
40 changes: 22 additions & 18 deletions docs/api-docs/slack_bolt/async_app.html
Original file line number Diff line number Diff line change
Expand Up @@ -1421,23 +1421,27 @@ <h2 id="args">Args</h2>
def _init_context(self, req: AsyncBoltRequest):
req.context[&#34;logger&#34;] = get_bolt_app_logger(app_name=self.name, base_logger=self._base_logger)
req.context[&#34;token&#34;] = self._token
if self._token is not None:
# This AsyncWebClient instance can be safely singleton
req.context[&#34;client&#34;] = self._async_client
else:
# Set a new dedicated instance for this request
client_per_request: AsyncWebClient = AsyncWebClient(
token=None, # the token will be set later
base_url=self._async_client.base_url,
timeout=self._async_client.timeout,
ssl=self._async_client.ssl,
proxy=self._async_client.proxy,
session=self._async_client.session,
trust_env_in_session=self._async_client.trust_env_in_session,
headers=self._async_client.headers,
team_id=req.context.team_id,
)
req.context[&#34;client&#34;] = client_per_request
# Prior to version 1.15, when the token is static, self._client was passed to `req.context`.
# The intention was to avoid creating a new instance per request
# in the interest of runtime performance/memory footprint optimization.
# However, developers may want to replace the token held by req.context.client in some situations.
# In this case, this behavior can result in thread-unsafe data modification on `self._client`.
# (`self._client` a.k.a. `app.client` is a singleton object per an App instance)
# Thus, we&#39;ve changed the behavior to create a new instance per request regardless of token argument
# in the App initialization starting v1.15.
# The overhead brought by this change is slight so that we believe that it is ignorable in any cases.
client_per_request: AsyncWebClient = AsyncWebClient(
token=self._token, # this can be None, and it can be set later on
base_url=self._async_client.base_url,
timeout=self._async_client.timeout,
ssl=self._async_client.ssl,
proxy=self._async_client.proxy,
session=self._async_client.session,
trust_env_in_session=self._async_client.trust_env_in_session,
headers=self._async_client.headers,
team_id=req.context.team_id,
)
req.context[&#34;client&#34;] = client_per_request

@staticmethod
def _to_listener_functions(
Expand Down Expand Up @@ -3884,7 +3888,7 @@ <h3>Class variables</h3>
**kwargs,
)
elif isinstance(text_or_whole_response, dict):
message: dict = text_or_whole_response
message: dict = create_copy(text_or_whole_response)
if &#34;channel&#34; not in message:
message[&#34;channel&#34;] = channel or self.channel
return await self.client.chat_postMessage(**message)
Expand Down
5 changes: 3 additions & 2 deletions docs/api-docs/slack_bolt/context/say/async_say.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ <h1 class="title">Module <code>slack_bolt.context.say.async_say</code></h1>
<pre><code class="python">from typing import Optional, Union, Dict, Sequence

from slack_bolt.context.say.internals import _can_say
from slack_bolt.util.utils import create_copy
from slack_sdk.models.attachments import Attachment
from slack_sdk.models.blocks import Block
from slack_sdk.web.async_client import AsyncWebClient
Expand Down Expand Up @@ -73,7 +74,7 @@ <h1 class="title">Module <code>slack_bolt.context.say.async_say</code></h1>
**kwargs,
)
elif isinstance(text_or_whole_response, dict):
message: dict = text_or_whole_response
message: dict = create_copy(text_or_whole_response)
if &#34;channel&#34; not in message:
message[&#34;channel&#34;] = channel or self.channel
return await self.client.chat_postMessage(**message)
Expand Down Expand Up @@ -140,7 +141,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
**kwargs,
)
elif isinstance(text_or_whole_response, dict):
message: dict = text_or_whole_response
message: dict = create_copy(text_or_whole_response)
if &#34;channel&#34; not in message:
message[&#34;channel&#34;] = channel or self.channel
return await self.client.chat_postMessage(**message)
Expand Down
2 changes: 1 addition & 1 deletion docs/api-docs/slack_bolt/context/say/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
**kwargs,
)
elif isinstance(text_or_whole_response, dict):
message: dict = text_or_whole_response
message: dict = create_copy(text_or_whole_response)
if &#34;channel&#34; not in message:
message[&#34;channel&#34;] = channel or self.channel
return self.client.chat_postMessage(**message)
Expand Down
5 changes: 3 additions & 2 deletions docs/api-docs/slack_bolt/context/say/say.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ <h1 class="title">Module <code>slack_bolt.context.say.say</code></h1>
from slack_sdk.web import SlackResponse

from slack_bolt.context.say.internals import _can_say
from slack_bolt.util.utils import create_copy


class Say:
Expand Down Expand Up @@ -74,7 +75,7 @@ <h1 class="title">Module <code>slack_bolt.context.say.say</code></h1>
**kwargs,
)
elif isinstance(text_or_whole_response, dict):
message: dict = text_or_whole_response
message: dict = create_copy(text_or_whole_response)
if &#34;channel&#34; not in message:
message[&#34;channel&#34;] = channel or self.channel
return self.client.chat_postMessage(**message)
Expand Down Expand Up @@ -141,7 +142,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
**kwargs,
)
elif isinstance(text_or_whole_response, dict):
message: dict = text_or_whole_response
message: dict = create_copy(text_or_whole_response)
if &#34;channel&#34; not in message:
message[&#34;channel&#34;] = channel or self.channel
return self.client.chat_postMessage(**message)
Expand Down
Loading

0 comments on commit 0ca2874

Please sign in to comment.