question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

module 'asyncio.base_futures' has no attribute 'InvalidStateError'

See original GitHub issue

Check this or we will delete your issue. (fill in the checkbox with an X like so: [x])

  • I have searched for other issues with the same problem or similar feature requests. (I found one old issue with same problem #18, but bug still exists.)

Select one:

  • Bug
  • Feature Request
  • Technical Help
  • Other

Environment

  • Are you using the module on a VPS or other Cloud hosting?
  • If so, have you tried running the code on your local machine?
  • Are you using the module on a Raspberry Pi?

Operating System? (include version)

  • macOS
  • Windows
  • Linux (Ubuntu 18.04.4 LTS)

Python Version Requirement

  • [X ] I am using Python 3.6.1 or above

Exact Python Version?

Python 3.8.3

Pip Version?

pip 20.1.1

Dependencies

Package                       Version    Location
----------------------------- ---------- ---------
alembic                       1.4.2
aniso8601                     8.0.0
attrs                         19.3.0
autobahn                      20.4.3
Automat                       20.2.0
certifi                       2020.4.5.1
cffi                          1.14.0
chardet                       3.0.4
cheroot                       8.3.0
click                         7.1.2
colorama                      0.4.3
constantly                    15.1.0
cryptography                  2.9.2
dateparser                    0.7.4
Flask                         1.1.2
Flask-RESTful                 0.3.8
flask-restx                   0.2.0
Flask-SQLAlchemy              2.4.3
hyperlink                     19.0.0
idna                          2.9
incremental                   17.5.0
inprofitapi                   0.1        /inprofit
itsdangerous                  1.1.0
jaraco.functools              3.0.1
Jinja2                        2.11.2
jsonschema                    3.2.0
Mako                          1.1.3
MarkupSafe                    1.1.1
more-itertools                8.3.0
pathlib                       1.0.1
pip                           20.1.1
psutil                        5.7.0
psycopg2-binary               2.8.5
pyasn1                        0.4.8
pyasn1-modules                0.2.8
pycparser                     2.20
PyHamcrest                    2.0.2
pyOpenSSL                     19.1.0
pyrsistent                    0.16.0
python-binance                0.7.5
python-dateutil               2.8.1
python-editor                 1.0.4
pytz                          2020.1
regex                         2020.5.14
requests                      2.23.0
service-identity              18.1.0
setuptools                    47.1.1
six                           1.15.0
SQLAlchemy                    1.3.17
Twisted                       20.3.0
txaio                         20.4.1
tzlocal                       2.1
ujson                         3.0.0
unicorn-binance-websocket-api 1.15.0
unicorn-fy                    0.4.1
urllib3                       1.25.9
websocket-client              0.57.0
websockets                    8.1
Werkzeug                      1.0.1
wheel                         0.34.2
zope.interface                5.1.0

UNICORN Binance WebSocket API Version?

Did you upgrade to the latest release version with `pip install unicorn-binance-websocket-api --upgrade`?
No. I am using version 1.15.0

Description of your issue

Debug log when streams crashed:

2020-06-08 16:05:14,701 - root - INFO - sent listen_key keepalive ping for stream_id=2ca0094e-8dea-46cf-af8d-8ac704876335
2020-06-08 16:35:14,721 - root - DEBUG - BinanceWebSocketApiRestclient->keepalive_listen_key(xImwgXC6A2tBWaxJR76frQLPJkwIEuttb7InMUaCgK8oTq8wU3PliQbEoq7PRysc)
2020-06-08 16:35:15,461 - root - INFO - sent listen_key keepalive ping for stream_id=2ca0094e-8dea-46cf-af8d-8ac704876335
2020-06-08 16:53:47,277 - root - DEBUG - BinanceWebSocketApiSocket->start_socket(76622917-8447-4e2a-b723-c2df11feebc2, ['kline_1m', 'kline_3m', 'kline_5m', 'kline_15m', 'kline_30m', 'kline_1h', 'kline_2h', 'kline_4h', 'kline_6h', 'kline_8h', 'kline_12h', 'kline_1d'], ['btcusdt', 'ethusdt', 'bchusdt', 'xrpusdt', 'eosusdt', 'ltcusdt', 'trxusdt', 'etcusdt', 'linkusdt', 'xlmusdt', 'adausdt', 'xmrusdt', 'dashusdt', 'zecusdt', 'xtzusdt', 'bnbusdt', 'atomusdt', 'ontusdt', 'iotausdt', 'batusdt', 'vetusdt', 'neousdt', 'qtumusdt', 'iostusdt']) Exception AttributeError Info: module 'asyncio.base_futures' has no attribute 'InvalidStateError'
2020-06-08 17:05:15,521 - root - DEBUG - BinanceWebSocketApiRestclient->keepalive_listen_key(xImwgXC6A2tBWaxJR76frQLPJkwIEuttb7InMUaCgK8oTq8wU3PliQbEoq7PRysc)
2020-06-08 17:05:15,928 - root - INFO - sent listen_key keepalive ping for stream_id=2ca0094e-8dea-46cf-af8d-8ac704876335
2020-06-08 17:35:15,973 - root - DEBUG - BinanceWebSocketApiRestclient->keepalive_listen_key(xImwgXC6A2tBWaxJR76frQLPJkwIEuttb7InMUaCgK8oTq8wU3PliQbEoq7PRysc)
2020-06-08 17:35:16,543 - root - INFO - sent listen_key keepalive ping for stream_id=2ca0094e-8dea-46cf-af8d-8ac704876335
2020-06-08 17:46:30,840 - root - DEBUG - BinanceWebSocketApiSocket->start_socket(27264e1f-532d-4293-933c-38e6f02cb0ad, ['arr'], ['!miniTicker']) Exception AttributeError Info: module 'asyncio.base_futures' has no attribute 'InvalidStateError'
2020-06-08 17:46:31,427 - root - DEBUG - BinanceWebSocketApiSocket->start_socket(2ca0094e-8dea-46cf-af8d-8ac704876335, ['arr'], ['!userData']) Exception AttributeError Info: module 'asyncio.base_futures' has no attribute 'InvalidStateError'
2020-06-08 18:05:16,621 - root - DEBUG - BinanceWebSocketApiRestclient->keepalive_listen_key(xImwgXC6A2tBWaxJR76frQLPJkwIEuttb7InMUaCgK8oTq8wU3PliQbEoq7PRysc)
2020-06-08 18:05:17,024 - root - INFO - sent listen_key keepalive ping for stream_id=2ca0094e-8dea-46cf-af8d-8ac704876335
2020-06-08 18:35:17,065 - root - DEBUG - BinanceWebSocketApiRestclient->keepalive_listen_key(xImwgXC6A2tBWaxJR76frQLPJkwIEuttb7InMUaCgK8oTq8wU3PliQbEoq7PRysc)
2020-06-08 18:35:17,539 - root - INFO - sent listen_key keepalive ping for stream_id=2ca0094e-8dea-46cf-af8d-8ac704876335
2020-06-08 19:05:17,635 - root - DEBUG - BinanceWebSocketApiRestclient->keepalive_listen_key(xImwgXC6A2tBWaxJR76frQLPJkwIEuttb7InMUaCgK8oTq8wU3PliQbEoq7PRysc)
Kline stream, and then other websocket streams (miniTicker, UserData) will shutdown without any error, exception after some time of work. It can happen in hours or days. Last time it worked almost 5 days.
I found some info about what happened in debug log, i added log above.
Last candle received in 16:53. After that no new data was added to database.
I assume that i must get exception from unicorn_binance_websocket_api_connection.py:268, but somehow i didn't have InvalidStateError.
Also it worries me because it was shutted down silently. No errors, no critical error or anything else. I was 

I ask for help to understand what caused this issue, my code or something wrong in library?
How i can avoid getting this error and stream crashing?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:25 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
Flowelcatcommented, Jun 10, 2020

Ok, changed version to 1.16.1.dev.

inprofitapi | 2020-06-10 09:51:42,228 - root - INFO - Initializing flask application...
inprofitapi | 2020-06-10 09:51:42,313 - root - INFO - Setting up kline subscription...
inprofitapi | 2020-06-10 09:51:42,315 - root - INFO - New instance of unicorn_binance_websocket_api_manager 1.16.1.dev started ...
inprofitapi | 2020-06-10 09:51:42,593 - root - INFO - Starting missing candles loader...
inprofitapi | 2020-06-10 09:51:42,598 - root - INFO - Setting up mark price subscription...
inprofitapi | 2020-06-10 09:51:42,599 - root - INFO - New instance of unicorn_binance_websocket_api_manager 1.16.1.dev started ...
inprofitapi | 2020-06-10 09:51:42,738 - root - INFO - Setting up mini ticker subscription...
inprofitapi | 2020-06-10 09:51:42,740 - root - INFO - New instance of unicorn_binance_websocket_api_manager 1.16.1.dev started ...
inprofitapi | 2020-06-10 09:51:42,858 - root - INFO - Setting up user data subscription...
inprofitapi | 2020-06-10 09:51:42,886 - root - INFO - New instance of unicorn_binance_websocket_api_manager 1.16.1.dev started ...
inprofitapi | 2020-06-10 09:51:43,047 - root - INFO - Starting flask application...
Read more comments on GitHub >

github_iconTop Results From Across the Web

module 'asyncio.base_futures' has no attribute 'InvalidStateError'
module 'asyncio.base_futures' has no attribute ... I found that in Python 3.8.0 and above InvalidStateError does not exists:.
Read more >
InvalidStateError with asyncio futures and RuntimeError with ...
But your main mistake is calling session.post() outside of ClientSession async context manager, the stacktrace explicitly points on it. I've ...
Read more >
Futures — Python 3.11.1 documentation
Future.exception() raise an InvalidStateError exception when the Future is not done. Callbacks registered with asyncio.Future ...
Read more >
Python Examples of asyncio.InvalidStateError
This page shows Python examples of asyncio.InvalidStateError. ... InvalidStateError: If PT has not yet started, or if the transport is not yet initialized....
Read more >
python3_lib Futures - CodeProject Reference
asyncio.Future.result() and asyncio.Future.exception() raise an InvalidStateError exception when the Future is not done. Callbacks registered with asyncio.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found