im new at (python, stackoverflow, tornado) , so please, be patient :). Correct me.
Im working with tornado on a real-time app. When i call self.close() inside the Websocket handler class , the on_close method is not fired up , for this time i did a little wrapper , fixing the problem and (for example) discarding that connected agent (pure avascript wss api client) correctly.
All network problems are discarded , since my poor wrapper is working nicely and im in a LAN enviroment.
is someone having the same problem ? I cant sleep without an explanation.
THANK YOU , really.
## imports and other stuff
AGENTS = set()
class BackofficeWSSRailMain(tornado.websocket.WebSocketHandler):
def on_open(self):
pass
def on_message(self,raw_message):
json_msg=json.loads(raw_message)
login = function_that_process_login(json_msg)
if login == True:
AGENTS.add(self)
self.write_message("ok")
else:
self.write_message("nologin")
self.close() ### this part should fireup
### the on_close method but nothing
### happens so AGENT is not discarded.
### here is when i actually call on_close_wrapper(),
### the method below.
def on_close_wrapper(self):
self.close() ### this is my actual solution ,
### waiting for more research.
self.on_close()
def on_close(self):
AGENTS.discard(self)
## Calling ioloop ...