Python DeprecationWarning in Exchange.close()
See original GitHub issue- OS: macOS 11.2
- Programming Language version: Python 3.9.1
- CCXT version:
ccxtpro==0.5.51
Reproduction steps
Run this script with python3 -W default script.py
.
import asyncio
from ccxtpro import ftx
async def main() -> None:
client = ftx()
ticker = await client.watch_ticker("BTC-PERP")
print(ticker)
await client.close()
print("Closing")
if __name__ == '__main__':
asyncio.run(main())
Results
A DeprecationWarning
is triggered:
.venv/bin/python -W default script.py
.venv/lib/python3.9/site-packages/ccxtpro/base/exchange.py:178: DeprecationWarning: The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8, and scheduled for removal in Python 3.11.
await asyncio.wait([client.close() for client in self.clients.values()], return_when=asyncio.ALL_COMPLETED)
{'symbol': 'BTC-PERP', 'timestamp': 1612340929250, 'datetime': '2021-02-03T08:28:49.250Z', 'high': None, 'low': None, 'bid': 36106.0, 'bidVolume': 0.0831, 'ask': 36107.0, 'askVolume': 18.6912, 'vwap': None, 'open': None, 'close': 36108.0, 'last': 36108.0, 'previousClose': None, 'change': None, 'percentage': None, 'average': None, 'baseVolume': None, 'quoteVolume': None, 'info': {'bid': 36106.0, 'ask': 36107.0, 'bidSize': 0.0831, 'askSize': 18.6912, 'last': 36108.0, 'time': 1612340929.2509072}}
Closing
Possible solution
The problem is in the Exchange.close()
method.
Replacing asyncio.wait()
with asyncio.gather()
resolves the problem.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10 (10 by maintainers)
Top Results From Across the Web
How to ignore deprecation warnings in Python - Stack Overflow
On the more serious note, you can pass the argument -Wi::DeprecationWarning on the command line to the interpreter to ignore the deprecation warnings....
Read more >python - Shapely deprecation warning message when plotting ...
Now I am having a new pc when I try to plot my geodataframe using : gdf.plot() there is no plot displayed and...
Read more >Changelog — Python 3.7.15 documentation
gh-97616: Fix multiplying a list by an integer ( list *= int ): detect the integer overflow when the new allocated length is...
Read more >Release notes for Python 3.5.4
bpo-29742: get_extra_info() raises exception if get called on closed ssl ... bpo-29349: Fix Python 2 syntax in code for building the documentation.
Read more >deprecationwarning: pkcs | The AI Search Engine You Control
BUILDROOT/python-pyOpenSSL-21.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/OpenSSL/SSL.py:1700: in _raise_ssl_error _raise_current_error() _ _ _ _ _ _ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@pietrodn I can confirm I am able to reproduce the bug, will need a bit more time to solve it
Hello @kroitor, I just tested with
ccxtpro==0.6.12
,ccxt==1.43.82
and confirm that the original issue is gone. Thank you! 🚀However I see another warning when executing the script with
python -X dev
(to enable all default warnings and asyncio debug mode).I can open another issue though, it looks like a separate problem.