"sleep" was never awaited - runtime warning
volcompt opened this issue · 6 comments
When I try to fetch data on some asins using:
api.query(asins, stats=None, domain='US', history=True,
offers=None, update=None, to_datetime=True,
rating=True, out_of_stock_as_nan=True, stock=False, product_code_is_asin=True)
I am getting the error below:
RuntimeWarning: coroutine 'sleep' was never awaited
asyncio.sleep(tdelay)
Also, the console just outputs every second that there are no tokens left instead of waiting for tokens to fill up.
Any idea on what is going on?
Are you using Keepa 1.3.0 or higher?
On 1.3.0, the async and sync interfaces were separated, so you can use the synchronous interface to not have those warnings.
If you wish to use the async interface just create an instance of keepa.AsyncKeepa('ENTER_ACTUAL_KEY_HERE')
I believe you can add wait=True to your parameters for it to wait.
Yes, I am using the latest API. making wait=TRUE helped with the error, but still I get a print every second of how many seconds wait to fill the tokens.
Below what I am doing in a nutshell. Not very familar with async.
accesskey = '' # enter real access key here
api = keepa.Keepa(accesskey)
asins = ['', '', '', '' ...] #long list of asins here
products = api.query(asins, stats=None, domain='US', history=True,
offers=None, update=None, to_datetime=True,
rating=True, out_of_stock_as_nan=True, stock=False, product_code_is_asin=True, wait=True)
Depending on your keepa subscription you will have a larger amount of tokens.
If you query the entire list of asins in one go, you might consume all your available tokens in one go (you can even be below zero).
Does the issue still happen for, let's say, a list of 2 or 3 asins?
I understand that. But the API in the past consumed all the tokens, and would yield a single message saying: "Waiting 600 seconds for new tokens". And waited. Which was fine.
Now it sends multiple messages:
"Waiting 600 seconds for new tokens"
"Waiting 599 seconds for new tokens"
"Waiting 698 seconds for new tokens"
etc
etc
I have no idea