-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unclosed client session and ddos Error for bitfinex #704
Labels
Comments
You don't need to do This code should work: import asyncio
import ccxt.async as ccxt
async def run():
bitfinex = ccxt.bitfinex({'enableRateLimit': True})
while True:
try:
bitfinexratio = await bitfinex.fetch_ticker('ETH/BTC')
bitfinexbtctry = await bitfinex.fetch_ticker('BTC/USD')
print('----------------------------------------')
datetimestring = bitfinex.iso8601(bitfinex.milliseconds())
print(datetimestring, bitfinexratio['last'], bitfinexbtctry['last'])
except Exception as e:
print(type(e).__name__ + ' ' + str(e))
asyncio.get_event_loop().run_until_complete(run()) More: |
Thanks a lot! now it is working i will look at basic Python courses as well (y) |
However, this one is much better: import asyncio
import ccxt.async as ccxt
async def run():
bitfinex = ccxt.bitfinex({'enableRateLimit': True})
while True:
try:
tickers = await bitfinex.fetch_tickers()
bitfinexratio = tickers['ETH/BTC']
bitfinexbtctry = tickers['BTC/USD']
print('----------------------------------------')
datetimestring = bitfinex.iso8601(bitfinex.milliseconds())
print(datetimestring, bitfinexratio['last'], bitfinexbtctry['last'])
except Exception as e:
print(type(e).__name__ + ' ' + str(e))
asyncio.get_event_loop().run_until_complete(run()) I'd recommend to fetch all tickers in one go like shown above if you need more than one of them. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
First, thanks for this amazing work you have done. Second my problem is about below code. I constantly get "Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x00000274BF7DAB38>" and Ddos error. I also tried to pu time.sleep(8) o get rid of it but didnt work. Is there any way to make it work efficiently? appreciate your help on this.
The text was updated successfully, but these errors were encountered: