Comments (6)
Hey @klmunday, thanks for reaching out.
This is indeed primarily a backend API issue which'll be fixed very soon.
From the library, you can in the meantime use the async/await handler instead. You would spawn a coroutine for each ASN, and then await them together. Something roughly like this (not tested and incomplete):
import asyncio
async def getAllAsns(asns):
return await asyncio.gather([
async_handler.getDetails(asn) for asn in asns
])
async def main():
results = await getAllAsns(["AS1", "AS2"])
print(results)
You mentioned possibly fixing the code around the requests.post
call, but I'm not fully clear on that - do you mean that we should catch the exception and not let it go up if raise_on_fail=False
, or something else?
from python.
Hey @UmanShahzad
Thanks for your response and help with emulating the behaviour of the batch operation that is very useful!
My main thought behind capturing the error regarding requests.post
was something similar to what you said. Although, when thinking about it, if the lookup errors at this stage then that entire bulk lookup fails, so i'm not actually sure that would be a good route to take since it would result in loss of data if only 1 item in the bulk caused the problem.
Perhaps wait and see until after the /batch
endpoint fix? I'm sure that would probably be suffice
from python.
@klmunday Although it wouldn't solve your problem, it would be worth capturing the error from requests.post
, because we send multiple requests when the total input size exceeds 1000 (the API limit), and we shouldn't throw an error in that case if raise_on_fail=False
, instead returning all successful chunks. It wasn't already being captured mainly because I didn't know requests.posts
would throw an exception... one of the issues with exceptions.
But yes, when /batch
is fixed to handle non-existent ASNs everything will go back to normal. Apologize for the inconvenience.
from python.
No worries, it does appear I was incorrect about getDetails
still working for the problematic ASNs. It seems to throw the same problems. I was about to get around this by directly using requests and checking to see if the resulting status code isn't 200, if it isn't then I just skip that ASN
edit: error occurs on line https://github.com/ipinfo/python/blob/master/ipinfo/handler.py#L90
seems to throw the same exceptions as the getBatchDetails
Thanks again
from python.
@klmunday it should work fine now, with the bad ASN having an error key:
$ curl ipinfo.io/AS1877?token=<token>
{
"error": "ASN Not Found!"
}
$ echo -e 'AS1877\nAS1878' | curl -XPOST --data-binary @- "https://ipinfo.io/batch?token=<token>"
{
"AS1878": {
"asn": "AS1878",
...
},
"AS1877": {
"error": "ASN Not Found!"
}
}
Let me know if it's solved and we can close this issue.
from python.
Can confirm both getBatchDetails
and getDetails
work with this fix.
Thanks a lot!
from python.
Related Issues (20)
- [SUPPORT] Is it possible to use this library connected to a local database rather than ipinfo.io server? HOT 2
- Total IP usage counted twice in IPinfo.io dashboard HOT 4
- JSON error on getDetails when it returns 5xx status code HOT 2
- get information is it proxy or vpn HOT 1
- Ip_Getnet HOT 1
- add a python program
- Unexpected 403 response HOT 4
- API don't work, returning useless info HOT 1
- Adding Proxy to Python Library HOT 3
- 4.3.0 release is giving an error HOT 2
- Async/Await unclosed connector HOT 5
- IPinfo 4.4.0 version Unicodeerror on initializing handler.
- Bogon check generates error if ip_address is None HOT 2
- Error when running program HOT 4
- Release v4.4.2 release doesn't contain the latest code HOT 1
- No such file HOT 11
- Runtime Error: Event Loop is Closed HOT 4
- Can't install ipinfo in Python 3.12 virtualenv HOT 3
- Inline all data files HOT 1
- response error HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python.