You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running run_forever() in the class WebSocketApp, the data from server is usually displayed (log). Is there any way to save (dump) this data into a variable inside the script?
The text was updated successfully, but these errors were encountered:
I've been doing something like what you're talking about involving dataframes. In my case, I'm creating a custom class and saving what I need to a class variable from within the class's "on_message" method, which is what my class's websocketapp calls when a message comes in. Alternatively, the functional approach would be to use a global that you can use elsewhere, like below.
messages=[]
def on_message(ws, message):
global messages
messages.append(message) #or whatever else you want to do.
I should point out that I have been struggling with issues as I scale things up. When I'm just receiving a few dozen messages per minute, there's no issue, but once I start receiving thousands, the delays that some of my calculations cause seem to be filling up a buffer somewhere (at least that's my theory at the moment). All of a sudden, I stop receiving messages, and don't get any error message to help sort things out. Again, this works at a small scale, so might be worth a shot for you.
I'm sure there's a way to handle all this with asyncio or maybe threading, but I'm still struggling with that part of it.
I think the answer from @M00NSH0T is a good approach. If you are looking at asyncio, issue #496 indicates that this library probably is not compatible, but I have not tested it myself. If you specifically want to handling log messages (which includes warnings, etc.) you can try using Sentry, which was referenced in issue #639.
When running run_forever() in the class WebSocketApp, the data from server is usually displayed (log). Is there any way to save (dump) this data into a variable inside the script?
The text was updated successfully, but these errors were encountered: