i have tornado server websockets:
class sockhandler(sockjsconnection): def on_open(self, request): clients.add(self) def on_message(self, message): if (message == 'start'): self.send({'message' : start_msg}) thr = threading.thread(target=func_with_loop, args=(self.on_result,)).start() if (message == 'next'): # resume 'thr' def on_result(self, response): self.send(response) # pause 'thr' def on_error(self, e): print(e) def on_close(self): clients.remove(self) self.close()
on ui have 'start' , 'next' buttons send these messages through socket connection.
i'm creating thread @ 'start' triggers function runs finite loop , calls callback self.on_result
in each loop.
this works fine right now. need execute commands @ 2 comments pause , resume thread.
how should achieve ?
Comments
Post a Comment