nats.py
nats.py copied to clipboard
Configurable concurrency level for messages processing
I have encountered some limitations of the client, I would like to set how many concurrent tasks can be created simultaneously for the subscription.
Currently it can be either one or unlimited (is_async=True
).
I found a comment in the client:
# NOTE: Deprecate this usage in a next release,
# the handler implementation ought to decide
# the concurrency level at which the messages
# should be processed.
We can take it a bit further and add ability to configure an exact number of running tasks per subscription.
It should relatively easy to implement using asyncio.Semaphore
.
What do you think about it? I would be happy to create a PR.
I think this is a great idea! I was wondering whether we could have a separate library that offers this behavior but having it as part of the client also sounds good
I would love to have concurrency when it comes to messages on a subscription, even unlimited. I can't find the is_async option, though. Is that outdated?