asyncio.base_futures.InvalidStateError: invalid state
See original GitHub issueCheck 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.
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?
Hardware
- Raspberry Pi
Operating System? (include version)
- macOS
- Windows
- Linux (include flavour)
Python Version Requirement
- I am using Python 3.5.3 or above
Exact Python Version?
Include here the response of 'python --version' or 'python3 --version'
Pip Version?
3.6
UNICORN Binance WebSocket API Version?
latest
Description of your issue
Sorry, I don’t know what is this. It just throws a bug after some hours running. Any ideas? If it don’t help, feel free to delete the issue.
Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/user/.local/lib/python3.6/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_manager.py", line 142, in _create_stream_thread
loop.run_until_complete(binance_websocket_api_socket.start_socket())
File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "/home/user/.local/lib/python3.6/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_socket.py", line 62, in start_socket
received_stream_data_json = await websocket.receive()
File "/home/user/.local/lib/python3.6/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_connection.py", line 183, in receive
received_data = await self.handler_binance_websocket_api_manager.websocket_list[self.stream_id].recv()
File "/home/user/.local/lib/python3.6/site-packages/websockets/protocol.py", line 441, in recv
self._put_message_waiter.set_result(None)
asyncio.base_futures.InvalidStateError: invalid state
Issue Analytics
- State:
- Created 4 years ago
- Comments:29 (28 by maintainers)
Top Results From Across the Web
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 >asyncio.base_futures.InvalidStateError: invalid state · Issue #169
I work with a raw sockets using asyncio.Lock to isolate blocks reading and sock_recv to communicate inside a Lock section. In a random...
Read more >Python Examples of asyncio.InvalidStateError
This page shows Python examples of asyncio.InvalidStateError.
Read more >Exceptions — Python 3.11.1 documentation
Changed in version 3.8: CancelledError is now a subclass of BaseException . exception asyncio.InvalidStateError¶. Invalid internal state of Task ...
Read more >Python AsyncIO Awaitables: Coroutine, Future, and Task
The Fundamentals of Python AsyncIO Application. ... In my last blog post “Python AsyncIO Event Loop”, ... InvalidStateError(f'{self.
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
Great! I am closing this issue! Best regards!
Very cool! 😃
To remind you: In this way you loose all data received during a down mysql database, because you have no error handling for such a case. If you work with the stream_buffer (working example: https://github.com/unicorn-data-analysis/unicorn-binance-websocket-api/blob/master/example_stream_buffer.py) you are able to avoid such loses… just a few lines of code and you can copy/paste. Just put your mysql code into the print stream buffer function to the print() section. thats all.
I would like to ask you, to run that script as it is for 2 more weeks to see if that bug is really caused the way we belief and is completely removed. I think this would help https://github.com/aaugustin/websockets/issues/634 - its the lib we are relying on for websocket operations and augustin is interested to investigate this issue.