dgzlopes / cloud-detect

Module that determines a host's cloud provider.
https://pypi.org/project/cloud-detect/
MIT License
35 stars 13 forks source link

Improve detection speed using asyncio #11

Closed kshivakumar closed 2 years ago

kshivakumar commented 2 years ago

I was testing this library on AWS EC2. It was stuck at the below line when I executed provider(). Hitting Ctrl+C printed 'aws' on the console and the program exited. https://github.com/dgzlopes/cloud-detect/blob/9ade138db41de1bdfa4a1f855f38f83d8c65cb95/cloud_detect/providers/alibaba_provider.py#L32

I am getting instant response with AWSProvider().identify()

Unlike files, url requests may take considerable time to respond even if the url is not accessible. So, identifying the cloud provider who's at the end of the if-clause(in init.py) could take lot of time.

All the providers' urls and files can be read concurrently using asyncio. That means irrespective of the position of a provider in the if-else clause, all providers would be detected within a similar duration.

I can create a PR in couple of days if this issue is accepted.

kshivakumar commented 2 years ago

@dgzlopes any update on this 👆🏽 ?

dgzlopes commented 2 years ago

Hey @kshivakumar! Sorry, December is a busy month and I was partly on vacation :smile:

From my POV, this would be a nice addition. Definitively if you create the PR, I will be happy to review/merge it :)

dgzlopes commented 2 years ago

Closing this one! Thanks again for the contrib :)