-
Notifications
You must be signed in to change notification settings - Fork 538
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
Pass self._streams as a list to subscribe() #363
base: master
Are you sure you want to change the base?
Conversation
Pass self._streams as a list (rather than a set) to _StreamConn.subscribe() because JSON can not encode a set
This PR was closed last week: #352 |
@shlomikushchi / @Shakespeare0 - My implementation was a bit different. I was casting to |
I'm not sure why @medusa-trade 's fix did not work, but |
I agree with @Shakespeare0. This seems like a better solution. I just haven't been able to test it. If it works across Python versions, I think it would be best to merge it. I honestly did dig into why my connections were hanging with my solution. I just know that when I removed those changes, it was still broke on my Ubuntu system with version 3.8.7, but it worked for my local 3.8.5. So I moved on. |
I think the connection hanging may be a different issue. Without this fix, rather than the connection hanging, I get the error |
I get 1006 errors ALLLLLLL THE TIME. Same thing Object of type set is not JSON serializable. Would love to see this fix merged in ASAP |
Merge? This is because Alpaca API gets disconnected midway. So the API tries to reconnect. But when it does so, the channels are not reinitialized, hence it remains a set that is not JSON serializable. Hence, in alpaca_trade_api > stream2.py change 'streams': channels to 'streams': list(channels) in line 132. |
If the connection drops and it tries to reconnect, it fails because the channels are saved in self._streams, which is a set, which is not serializable in JSON, so convert it back to a list when passing the channels to _StreamConn.subscribe().