To be able to get a subscriber by id / name and stop / start it #2589
-
|
Hi, I have a pod running on K8S. Whenever I upgrade my service, I receive a signal in my pyhon app to inform me that the pod is trying to shutdown. At that point, I want to stop treating new events, but to finish the treatment that were ongoing. My 1st idea would be to do something such as: Or to use the broker the same way. But it doesn't seem to be possible. Is there a way to do it without using the dynamic subscriber creation... which is much less documented and pleasant to use ?(much more to manage manually) Regards, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Why not? You can create subscriber object, store it somewhere and use it as a decorator later sub = broker.subscriber(...)
@sub
async def handler(): ...
subscribers = {"sub_id": sub}I don't think, that the case relates to framework - it is just about code organization |
Beta Was this translation helpful? Give feedback.
-
|
Thats quite elegant... didn't think about that way to write it. Thank you. |
Beta Was this translation helpful? Give feedback.
Why not? You can create subscriber object, store it somewhere and use it as a decorator later
I don't think, that the case relates to framework - it is just about code organization