-
Notifications
You must be signed in to change notification settings - Fork 772
Closed
Description
Hello all,
I am running multiple WebSocketApps, but I also have a requirement to call back on methods, for various reasons such as, the websockets (WS) session is valid for 24 hours at most and the WS session may disconnect (obviously or silently).
When I try callbacks of the form:
rel.abort()
for socket in [self.user_data_socket, self.mkt_data_socket]:
ws = websocket.WebSocketApp(
socket, on_open=self.on_open, on_message=self.on_message,
on_error=self.on_error, on_close=self.on_close
)
# noinspection PyTypeChecker
ws.run_forever(
dispatcher=rel, skip_utf8_validation=True, sslopt=SSL_OPT, reconnect=3,
)
threading.Timer(
interval=24 * 60 * 60 - 60, function=self.subscriptions
).start()
rel.dispatch()
I get an error when threading.Timer tries to call back on that method:
ValueError: signal only works in main thread
Clearly since introducing rel, I must use a different approach to method callbacks. But how?
I did try approaches such as the following, which threw errors:
def method(self):
# do something
rel.signal(60, self.method)
Thanks in advance.
Metadata
Metadata
Assignees
Labels
No labels