-
Notifications
You must be signed in to change notification settings - Fork 177
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
Async support. #149
base: main
Are you sure you want to change the base?
Async support. #149
Conversation
4.0 seems like a great time to drop support for Python <3.5. What do you have in mind for the pieces of the API that should have async versions? Timing coroutines like you've done here is definitely important.
Ah I've never moved this package over to using GitHub Actions for tests. In the meantime, running tox or |
So should I change this PR to be Python 3.5 or greater? Things would be simpler but a lot is not async specific (ex. I just added a commit for what I'm thinking for an async version. It's basically... not async. We could have async versions of Got the tests running. Thanks. Doesn't look like I've broken anything but I'll try adding some tests for this new stuff. |
If performance isn't a consideration here, just out of curiosity, how this change affects the performance? And how would it affect the performance if the network requests also use asyncio? |
Not sure I follow 100%. I think performance is a consideration, it's what impact we want a performance degradation to have that I was trying to describe. Specifically, this change means that in an async environment, if there is a performance issue in doing network IO related to metrics, that will only impact metrics and NOT block the event loop (which would typically be considered really bad). There's also the performance-related question of whether it's faster to put something in a Python queue or to send data over a socket. I think for the default (UDP) client, it's not a significant difference. If statsd did it's network requests using asyncio (or trio or anyio: worth keeping in mind that asyncio isn't the only game in town) on the same thread, that could negatively impact application performance. It wouldn't block the event loop, but the particular statsd call would slow down the coroutine calling it. Like it does right now for synchronous code, hence why UDP is desirable. |
* Clone use cases from the use case store as draft * Upgrade requirements and precommits
I'd like to use statsd for an async codebase I have. Hoping to start adding proper support. I believe this can be done without doubling the API surface area (not every part of the API should be async) and without dropping support for Python 2 (although if we only had to support Python 3.5+ as per milestone 4.0, the code would be a bit cleaner).
The first commit just starts simple by allowing timing of coroutine functions. Still outstanding is actually doing asynchronous IO or synchronous IO on a background thread. I'll work on that next. Submitting this PR now to potentially kick off any required discussion and review the general approach.
Doc changes included in this PR.
I couldn't figure out how the tests work so haven't run or touched those. Maybe someone can help.