-
Notifications
You must be signed in to change notification settings - Fork 853
Revised sync mode WebClient/RTMClient to address concurrency issues #662
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
Changes from all commits
86a15f9
f9de16b
baef25d
b86a8fc
60b2227
58feb63
8ed73d2
2bea8d7
130f3a0
c8866d4
227f949
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,15 +35,15 @@ def tearDown(self): | |
| if hasattr(self, "rtm_client") and not self.rtm_client._stopped: | ||
| self.rtm_client.stop() | ||
|
|
||
| @pytest.mark.skipif(condition=is_not_specified(), reason="this is just for reference") | ||
| @pytest.mark.skipif(condition=is_not_specified(), reason="to avoid rate_limited errors") | ||
| def test_issue_631_sharing_event_loop(self): | ||
| self.success = None | ||
| self.text = "This message was sent to verify issue #631" | ||
|
|
||
| self.rtm_client = RTMClient( | ||
| token=self.bot_token, | ||
| run_async=False, # even though run_async=False, handlers for RTM events can be a coroutine | ||
| loop=asyncio.new_event_loop(), # TODO: remove this | ||
| run_async=False, | ||
| loop=asyncio.new_event_loop(), # TODO: this doesn't work without this | ||
| ) | ||
|
|
||
| # @RTMClient.run_on(event="message") | ||
|
|
@@ -72,8 +72,7 @@ def test_issue_631_sharing_event_loop(self): | |
|
|
||
| # Solution (1) for #631 | ||
| @RTMClient.run_on(event="message") | ||
| # even though run_async=False, handlers for RTM events can be a coroutine | ||
| async def send_reply(**payload): | ||
| def send_reply(**payload): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. coroutines no longer work when |
||
| self.logger.debug(payload) | ||
| data = payload['data'] | ||
| web_client = payload['web_client'] | ||
|
|
@@ -82,7 +81,7 @@ async def send_reply(**payload): | |
| if "text" in data and self.text in data["text"]: | ||
| channel_id = data['channel'] | ||
| thread_ts = data['ts'] | ||
| self.success = await web_client.chat_postMessage( | ||
| self.success = web_client.chat_postMessage( | ||
| channel=channel_id, | ||
| text="Thanks!", | ||
| thread_ts=thread_ts | ||
|
|
@@ -106,7 +105,6 @@ def connect(): | |
| self.web_client = WebClient( | ||
| token=self.bot_token, | ||
| run_async=False, | ||
| loop=asyncio.new_event_loop(), # TODO: this doesn't work without this | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary as |
||
| ) | ||
| new_message = self.web_client.chat_postMessage(channel=self.channel_id, text=self.text) | ||
| self.assertFalse("error" in new_message) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ | |
| ) | ||
|
|
||
|
|
||
| # This doesn't work | ||
| # Fixed in 2.6.0: This doesn't work | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| @app.route("/sync/singleton", methods=["GET"]) | ||
| def singleton(): | ||
| try: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#662 fixes both #530 and #613