netbox-python icon indicating copy to clipboard operation
netbox-python copied to clipboard

feat: Include Async support

Open arthanson opened this issue 2 years ago • 9 comments

Feature Request

Describe the Feature Request

Request was made to potentially add async support.

arthanson avatar Mar 30 '23 23:03 arthanson

What about using FastAPI framework?

emersonfelipesp avatar Apr 18 '23 13:04 emersonfelipesp

I would love to see async support.

meibenny avatar May 03 '23 22:05 meibenny

Absolutely. Using NetBox API is IMO a prime candidate for async: some calls often take a long time to execute, and giving the client a flexible possibility to do other tasks meanwhile is important.

requests made API calls easy, but it won't get async support. I think it shouldn't be used in new API wrappers anymore. There are other options that support async and are used in very similar way to requests.

markkuleinio avatar May 04 '23 04:05 markkuleinio

There was some discussion in slack about using aiohttp or httpx

meibenny avatar May 04 '23 17:05 meibenny

Here is a good overview: https://www.scrapingbee.com/blog/best-python-http-clients/

I'm leaning towards httpx (https://github.com/encode/httpx/), seems to have all the features of aiohttp and supports http2 if needed, also more compatible with the current requests library. Interest in it (from github stars and such, seems to be growing faster then aiohttp).

arthanson avatar May 04 '23 19:05 arthanson

It makes sense to me to use a library that's compatible with requests, has async support, and a large community behind it. I'm not sure what, if anything, aiohttp offers over httpx.

meibenny avatar May 05 '23 18:05 meibenny

I use httpx a lot for internal API clients and it's a great library. The lead maintainer is the same behind Django REST Framework and really knows HTTP.

The httpx APIs for async and sync are nearly identical, so it's quite easy to mix the two. I'd highly recommend it.

tyler-8 avatar May 09 '23 21:05 tyler-8

Uplink is a declarative HTTP client, which supports both sync and async I/O: https://github.com/prkumar/uplink

drygdryg avatar Jun 15 '23 07:06 drygdryg

I'd be interested in updating this with async support via httpx. I have it "working" currently minus some of the features in baseapi like all(). This is by shimming over your current implementation, but can pluck the changes to a PR to get async running.

However, your setup docs mention poetry, but I think that is out of date? Any chance you could let me know how to get the dev environment tooling setup?

deranjer avatar Jan 13 '24 00:01 deranjer