Closed girishk14 closed 8 years ago
when asking for articles from an event you can only request articles for a single event per call. If specifying more than a single event uri you can only request event info (RequestEventInfo()).
But the documentation says that the limit is a list of a maximum of 200 events at a time, to query articles. And this worked intitially for me.
Yes, but the query was too intense so I had to change it. You can still get 200 events at a time, but only basic event information.
On Wed, Jul 27, 2016 at 2:04 AM, Girish K notifications@github.com wrote:
But the documentation says that the limit is a list of a maximum of 200 events at a time, to query articles. And this worked intitially for me.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/gregorleban/EventRegistry/issues/9#issuecomment-235443327, or mute the thread https://github.com/notifications/unsubscribe-auth/AAxauklUfT0pjZwKKSyDQC__-BgrONkWks5qZqCVgaJpZM4JTdhL .
Gregor
I guess the main issue I am facing is, er.getRemainingAvailableRequests() always returns -1, instead of the actual limit, which is making it hard for me to write a crob job that restarts everyday once the limit is over.
Is there any other way in the API for me to tell the code that the limit for the day is over?
er.getRemainingAvailableRequests() works just fine. The remaining requests get updated from the response headers after making a request. Here is a working example:
er = EventRegistry()
q = QueryEvents(conceptUri = er.getConceptUri("sandra bullock"))
q.addRequestedResult(RequestEventsInfo(page=1, count=1))
er.execQuery(q)
print er.getRemainingAvailableRequests()
Note that you should not create a separate instance of EventRegistry() class for each query that you make. Make one instance and reuse it. Otherwise, each time you create an instance, the logging-in has to be performed which requires another call to the server which is completely unnecessary.
Ok you are right. After making the first request, the er.getRemainingAvailbleRequests() works, and gets updated with each successive call.
The problem I'm facing is that, if the limit for the day is already over, then the value doesn't get updated, and returns -1 all the time, which makes it hard for my code to differentiate between that error, and other errors.
Yes, I am using only a single instance that is initialized and logs at time of object creation. The member function then do the invocations.
Are you using the python module that is currently on github/pypi? The current version checks if the obtained status_code is 200. If not, an exception is raised and the request is repeated in 10 seconds. In this way, you don't have to check or modify anything in your code.
I have a list of event uris that I want to get articles for:
So I'm trying a while loop to iterate the list and make requests. The list has about 6000 URIs, so it will take about 6 days I guess, which I don't really mind.
` while True:
if self.er.getRemainingAvailableRequests() <= 5 :
logger.info('Daily Limit Over! Sleeping for some time')
time.sleep(60 * 60 * 4)
else:
#Code to query articles and process the
`
I really appreciate your replies in helping me out :) Thank you!
Hi,
I would like to know the procedure for requesting for more usage limit, or at least discuss a way to prevent my account getting locked.