nats.py icon indicating copy to clipboard operation
nats.py copied to clipboard

Configurable concurrency level for messages processing

Open maruqu opened this issue 5 years ago • 8 comments

This PR adds max_cb_concurrency parameter to subscribe method. Concurrent cb execution limit is achieved using asyncio.Semaphore.

TO DISCUSS:

  • [x] What should be a default max concurrency parameter
  • [x] Should we deprecate is_async parameter (seems redundant and a bit misleading now)

Resolves #119

maruqu avatar Dec 02 '19 17:12 maruqu

Thanks for the contribution! About the discussion points you mention:

What should be a default max concurrency parameter

I think default max concurrency should be still one following the example of the Go client

Should we deprecate is_async parameter (seems redundant and a bit misleading now)

Yes we should deprecate this, probably do the same with subscribe_async, document that this is controlled by the concurrency level field now. We can do this in a separate PR.

wallyqs avatar Dec 02 '19 22:12 wallyqs

@wallyqs can you fix ClientTLSTest tests and document the changes in next PR?

maruqu avatar Dec 03 '19 16:12 maruqu

Sorry the the TLS certs needed and update for the tests to pass (fixed via https://github.com/nats-io/nats.py/pull/123), if you rebase you should get the changes now.

wallyqs avatar Dec 03 '19 20:12 wallyqs

@wallyqs What do you think? Did I go too far with the refactor?

maruqu avatar Dec 06 '19 17:12 maruqu

@maruqu I think it looks great! Also good to have a few things cleaned up finally

wallyqs avatar Dec 06 '19 23:12 wallyqs

@wallyqs I am glad I could help. Can you release a new package version containing this change? Maybe an alpha?

maruqu avatar Dec 18 '19 13:12 maruqu

Is this the MaxInFlight behavior of the Go client?

hvt avatar Mar 19 '20 13:03 hvt

Will anybody resolve this PR or it will be other concurrency level tools in the library?

Positron1990 avatar Apr 18 '22 15:04 Positron1990