-
Notifications
You must be signed in to change notification settings - Fork 24
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
Thespian + RabbitMQ (Pika) #47
Comments
Both Thespian and Pika provide scheduling capabilities, so it can be difficult to combine different frameworks that are attempting to implement the same feature. I think the best approach here (I haven't done this myself, so this is based on a high-level assessment of Pika) would be to combine the Thespian Watch functionality (https://thespianpy.com/doc/using.html#hH-94edef18-154e-4847-864f-027dff4f6e0a) with the Pika At the core, Thespian implements a Roughly this would mean creating a custom |
Thanks a lot for in depth clarification. I will try this solution although it seems more complicated than i thougth asking the question ;) |
To some extent, Thespian and an event bus exist in the same solution space, so the overlap can be a bit hard to resolve. Thespian is written to allow multiple transport layers to be created however, so ideally a message bus transport layer could use RabbitMQ as the communications layer between Thespian Actors. At present, I don't know of a lot of interest in a solution like this other than yours, so I'm hesitant to commit much time and effort to implementing this approach. |
If such integration existed, I would probably use it. This certainly doesn't qualify as 'a lot of interest', but two is certainly better than one! Thespian looks very promising for what I need. Great work! |
I'd like to use this issue to gather more input on the usage model (and interest level) for using Thespian and RabbitMQ together. My assumption would be that there is an existing RabbitMQ network with clients and that a particular client would also wish to use Thespian to implement its functionality like below:
In this configuration, the "Client" would be capable of talking to both the RabbitMQ bus to send and receive messages there, as well as to Thespian Actors to send and receive messages on that side as well. The "Client" would be the primary interface between the two otherwise independent environments. Please let me know if the above represents the usage model needed or if there is other functionality or considerations that would need to be addressed. To anyone else desiring this functionality: please up-vote this issue so that I can determine how much interest there is in having this implemented. |
That´s exactly it!
Thanks!
Em sex., 22 de nov. de 2019 às 13:21, Kevin Quick <notifications@github.com>
escreveu:
… I'd like to use this issue to gather more input on the usage model (and
interest level) for using Thespian and RabbitMQ together. My assumption
would be that there is an existing RabbitMQ network with clients and that a
particular client would also wish to use Thespian to implement its
functionality like below:
Thespian Actor
RabbitMQ Bus /
------------------------------> Client ------------ Thespian Actor
\
Thespian Actor
In this configuration, the "Client" would be capable of talking to both
the RabbitMQ bus to send and receive messages there, as well as to Thespian
Actors to send and receive messages on that side as well. The "Client"
would be the primary interface between the two otherwise independent
environments.
Please let me know if the above represents the usage model needed or if
there is other functionality or considerations that would need to be
addressed.
To anyone else desiring this functionality: please up-vote this issue so
that I can determine how much interest there is in having this implemented.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#47?email_source=notifications&email_token=AA6QP4PRMRHH6MCX4TV7QJDQVABHHA5CNFSM4IZDIPS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE6EDUY#issuecomment-557597139>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA6QP4LY3B3PEVBUHFEAQ7TQVABHHANCNFSM4IZDIPSQ>
.
--
Rodrigo Botafogo
|
That model is exactly what we need |
Ok so i have tried to implement this. Unfortunately without a success. There are some major problems with that approach. Problem number 1:
Pika uses all 3 types of events: read, write and error for negotiating a connection and sending and receiving messages. Thespian watch functionality only allows for a partial implementation of this. So we do not have a solution that covers all requirements and fits well to an actor life cycle and design pattern. Write and error events must be implemented somehow differently than read events possibly blocking and breaking the normal and desired nature of an actor processing Problem number 2:
Pika event loop uses timeouts extensively. And it seems for me that wake up messages do not work well in that case.
for example:
does this mean that we are leaking resources here? will now thespian still watch for events on both file descriptors: 1 and 2 even if right now pika do not requires observing file descriptor 1? and another example for the same code:
it looks like wake up message will be always delivered first before the watch message. Ok we can just simply use a slightly higher timeout (what makes at the other side an undesired slowdown):
but it still looks like overcomplicated solution for something that should be simply implemented directly in thespian api in a such way:
Problem number 3: ok so the code: script to start local rabbitmq instance (in docker):
custom SelectPooler and IOLoop:
an actor communicating with a rabbitmq instance:
and this code doesn't work because at several attempts only once was with successful connection to rabbitmq instance (ON_CONNECTION_OPEN). 99% of attempts were unsuccessful
as you can see i started to use normal python select api for watching for all events (read, write, error) and after that i additionally yield file descriptors to thespian to watch for read events but with timeout 0. I expect that thespian watch should give me the same results as normal python select api (i suppose that pika is blocked in the meantime and nothing is reading from this ready for read file descriptors). And for the most of the time results are indeed the same but not always:
And after all of that one another problem occured. I noticed strange intervals of logging inactivity. It looks like logging regularly freeze for at least 4-5 minutes. So i see normal info outputs and suddenly output stops showing for at least 4 minutes. And then a bunch of logs is printed at once to terminal and once again logging stops showing. If i change one of the "info" logging to simply "print" then i see that code is still running but the rest info logs stuck somewhere at the logger actor:
Any help appreciated ;-) I use thespian==3.10.1 |
Hi @htarnacki . I just returned from vacation and wanted to let you know I've seen this report. There's a lot here, so I will need a day or so to digest this and be able to respond. |
There is no resource leakage on the Thespian side for this. Thespian will only listen on file descriptors returned in the most recent |
I think that might be a potential to extend the ThespianWatch to include I'm somewhat concerned that write and error conditions are local and can be persistent, so it's possible to get into situations where the use of these prevents even normal functionality, but since this is an issue with any use of If the ability to wait on write and error conditions still sounds useful, I can see about putting together some initial support for that which could be tested, but let me know if this is still the case after reading some of my other responses on this issue. |
I think this is probably providing some useful insight into some of the otherwise invisible functionality going on. First some background though: In Thespian, there is a flow control mechanism that will cause an actor to suspend incoming activity for a period of time if the number of queued outbound messages exceeds a threshold value. This is intended to let the actor complete the current processing and send out the corresponding results before accepting new work that will result in additional processing demands. Also, Thespian modifies the Given this background, I believe the reason that you are seeing the logging delays is because pika is starting up multiple threads and some of those threads are generating (perhaps large amounts of) logging at a low severity level (e.g. Based on the behavior, I believe that pika does have other threads running, which could also be affecting the difference in the Since the model we described earlier in this thread is that of a
This configuration separates all of the processing scheduling of Thespian and pika into two separate process domains where they don't conflict with each other or need to be tightly integrated. The Does this ClientActor/PikaClient approach sound reasonable for your needs? |
hi, |
OK @htarnacki , that sounds good. Good luck and let me know if you run into issues. |
In my actor based application I want to use Thespian actors along with the Pika integration to RabbitMQ instance. My problem is: what should be the best pattern of such integration? In other words: how to read RabbitMQ messages delivered by Pika to one of a Thespian actor? In a non blocking and best asynchronous way?
The text was updated successfully, but these errors were encountered: