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
AsyncIO loop is not being shared from RTMClient to WebClient #631
Comments
FYI: this commit contains a test case reproducing this issue and it shows two possible solutions for it even with slackclient 2.5.0. seratch@6fb4287 In the forthcoming release, the library will address the issue for The internal modification won't bring any breaking changes to the library users. |
On the other hand, for the If you manually create a WebClient, you can set your own loop (as you can do on RTMClient creation) |
I've updated the demo code to highlight the workaround I've made and need to be solved by doing the proper loop/run_async params passing from RTMClient to WebClient |
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine * slackapi#569 Resolved by removing a blocking loop (while future.running()) * slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default * slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp * slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop * slackapi#630 WebClient no longer depends on aiohttp when run_async=False * slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine * slackapi#569 Resolved by removing a blocking loop (while future.running()) * slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default * slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp * slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop * slackapi#630 WebClient no longer depends on aiohttp when run_async=False * slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine * slackapi#569 Resolved by removing a blocking loop (while future.running()) * slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default * slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp * slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop * slackapi#630 WebClient no longer depends on aiohttp when run_async=False * slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine * slackapi#569 Resolved by removing a blocking loop (while future.running()) * slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default * slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp * slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop * slackapi#630 WebClient no longer depends on aiohttp when run_async=False * slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine * slackapi#569 Resolved by removing a blocking loop (while future.running()) * slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default * slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp * slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop * slackapi#630 WebClient no longer depends on aiohttp when run_async=False * slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine * slackapi#569 Resolved by removing a blocking loop (while future.running()) * slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default * slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp * slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop * slackapi#630 WebClient no longer depends on aiohttp when run_async=False * slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine * slackapi#569 Resolved by removing a blocking loop (while future.running()) * slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default * slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp * slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop * slackapi#630 WebClient no longer depends on aiohttp when run_async=False * slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine * slackapi#569 Resolved by removing a blocking loop (while future.running()) * slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default * slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp * slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop * slackapi#630 WebClient no longer depends on aiohttp when run_async=False * slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine * slackapi#569 Resolved by removing a blocking loop (while future.running()) * slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default * slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp * slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop * slackapi#630 WebClient no longer depends on aiohttp when run_async=False * slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine * slackapi#569 Resolved by removing a blocking loop (while future.running()) * slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default * slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp * slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop * slackapi#630 WebClient no longer depends on aiohttp when run_async=False * slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine * slackapi#569 Resolved by removing a blocking loop (while future.running()) * slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default * slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp * slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop * slackapi#630 WebClient no longer depends on aiohttp when run_async=False * slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine * slackapi#569 Resolved by removing a blocking loop (while future.running()) * slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default * slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp * slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop * slackapi#630 WebClient no longer depends on aiohttp when run_async=False * slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine * slackapi#569 Resolved by removing a blocking loop (while future.running()) * slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default * slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp * slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop * slackapi#630 WebClient no longer depends on aiohttp when run_async=False * slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
Let me close this issue now as #662 resolved this for the |
👋 slackclient 2.6.0rc1 is out. The pre-release version contains fixes for your issue described here. One week later from now, we'll be releasing version 2.6.0 to PyPI. If you have a chance, could you try the release candidate version out and let us know your feedback? Thank you very much for being patient with this issue. |
Description
Describe your issue here.
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
slackclient version: 2.5.0
python version: 3.7.6 (venv)
Steps to reproduce:
asyncio.get_event_loop()
in order to use the same as the projectweb_client
and use it to send a message backExpected result:
The message is sent
Actual result:
RuntimeError: this event loop is already running.
Explanation of what's going on and workaround:
What is actually happening is that the loop set to the RTMClient is not being shared with the attached WebClient.
The following code does the trick, but it's a workaround and not a real solution
Regarding uvloop:
If the main project's loop is not the common one but an uvloop, you will need to make some mods before getting the loop in order to set it on the RTMClient
The text was updated successfully, but these errors were encountered: