--
You received this message because you are subscribed to the Google Groups "Pika" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pika-python...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/9f1f3111-4ed9-4ed4-860e-1ad250287025n%40googlegroups.com.
James McKinney
Head of Technology
+1-514-247-0223 | @mckinneyjames | timezone: EST
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAJNoxVe9cHbJp7NP42ewgw4FYtfTb7tPpLg51bvdgWHMWBmdqg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAJNoxVe9cHbJp7NP42ewgw4FYtfTb7tPpLg51bvdgWHMWBmdqg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAPnH5kpN%3DaAVHY-sUTfi1c8zNxC%2B0ZsVHsF6WVFa%3DVOZtZNxAQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAJNoxVe9LZj7ftfmHh1-F2yrF7GSb1mjcKDj%2B4QmmxZ9G1pAuw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAPnH5kqTJps8nDqs8THhusxDOxvTqFz-emKODJYdtwFu35QArg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAJNoxVc7h6ik%2Bd79hV2oYj5Ti0C_fYCRksMiZ8Xt97J7CnuSNQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAPnH5kott9BMDSogwE%2B9jT5sikQ_3kLQu2xAw6H4dCG%3Ddy95BQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAJNoxVfiOrAeANgtMnP347Sn8%3DE-NNWTmd67r%2BqFpDFXaMdDXg%40mail.gmail.com.
Sorry I was not clear.1. Threads should not be intermixed in the actual pika client usage. It's very easy to get threading wrong and have incorrect protocol behaviors.2. I would absolutely use asyncio over the IOLoop in the SelectConnection. There's a whole ecosystem around asyncio in Python3 you benefit from. If asyncio existed when I wrote SelectConnection, I wouldn't have written SelectConnection or it's IOLoop.3. The idea behind the threaded executor is you let the asyncio loop manage the background execution of CPU intensive tasks in a way that doesn't interrupt or change the context of IOLoop and the things running on it.Â
More context: amqp is a bidirectional RPC protocol. To do it right, the client library should be able to respond in real time to RPCs from the server to the client. It also expects strict sequencing of RPC frames. Introducing threads that are aware of pika connections and channels introduces the ability to intersperse RPCs frames in a way that breaks the protocol. Instead if you receive a message for example, then dispatch the work via a thread pool executor managed by the IOLoop, the client usage stays non-threaded, while compute heave work is processed "in the background" and returns from the function when complete as if it were just a normal execution of a function on the ioloop.
On Sun, Jul 2, 2023 at 12:01 PM James McKinney <jmckinney@open-contracting.org> wrote:
At first you said threads shouldn't be used, but they are fine to use for compute heavy work?If I'm using the SelectConnection, would I use the ThreadPoolExecutor from concurrent.futures instead?Or, do you recommend AsyncioConnection over SelectConnection, anyway?
On Sun, Jul 2, 2023 at 11:39 AM Gavin M. Roy <gavi...@gmail.com> wrote:
If you're thinking of doing compute heavy work on an IOLoop you should consider using the ThreadPoolExecutor for that processing with the IOLoop staying in the foreground. See https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.run_in_executor
To unsubscribe from this group and stop receiving emails from it, send an email to pika-python+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/9f1f3111-4ed9-4ed4-860e-1ad250287025n%40googlegroups.com.
----James McKinney
Head of Technology
+1-514-247-0223 | @mckinneyjames | timezone: EST
💙💛 Learn how we are supporting Ukraine's Reconstruction here #URC2023 💙💛
You received this message because you are subscribed to the Google Groups "Pika" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pika-python+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAJNoxVe9cHbJp7NP42ewgw4FYtfTb7tPpLg51bvdgWHMWBmdqg%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Pika" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pika-python+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAPnH5kpN%3DaAVHY-sUTfi1c8zNxC%2B0ZsVHsF6WVFa%3DVOZtZNxAQ%40mail.gmail.com.
----James McKinney
Head of Technology
+1-514-247-0223 | @mckinneyjames | timezone: EST
💙💛 Learn how we are supporting Ukraine's Reconstruction here #URC2023 💙💛
You received this message because you are subscribed to the Google Groups "Pika" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pika-python+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAJNoxVe9LZj7ftfmHh1-F2yrF7GSb1mjcKDj%2B4QmmxZ9G1pAuw%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Pika" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pika-python+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAPnH5kqTJps8nDqs8THhusxDOxvTqFz-emKODJYdtwFu35QArg%40mail.gmail.com.
----James McKinney
Head of Technology
+1-514-247-0223 | @mckinneyjames | timezone: EST
💙💛 Learn how we are supporting Ukraine's Reconstruction here #URC2023 💙💛
You received this message because you are subscribed to the Google Groups "Pika" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pika-python+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAJNoxVc7h6ik%2Bd79hV2oYj5Ti0C_fYCRksMiZ8Xt97J7CnuSNQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Pika" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pika-python+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAPnH5kott9BMDSogwE%2B9jT5sikQ_3kLQu2xAw6H4dCG%3Ddy95BQ%40mail.gmail.com.
----James McKinney
Head of Technology
+1-514-247-0223 | @mckinneyjames | timezone: EST
💙💛 Learn how we are supporting Ukraine's Reconstruction here #URC2023 💙💛
You received this message because you are subscribed to the Google Groups "Pika" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pika-python+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAJNoxVfiOrAeANgtMnP347Sn8%3DE-NNWTmd67r%2BqFpDFXaMdDXg%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Pika" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pika-python+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pika-python/CAPnH5kpW9kMV%2BOy2mq%3DWMeFJG39Nq_3oJ1p%2B_0hTOq1jHEvNog%40mail.gmail.com.