smab / playhouse-web

GNU Affero General Public License v3.0
0 stars 2 forks source link

[games] Weird issue with closed sockets remaining #25

Closed FireyFly closed 10 years ago

FireyFly commented 10 years ago

For some weird reason, sometimes when switching games closed sockets seem to be lying around in self.connections and thus cause an error when destroy is invoked.

This is weird, because amongst others it seems to happen for the 'Paint' game, which overrides on_connect, so no sockets should be added to this list in the first place... further investigation is needed.

lightgames: destroy {<__main__.CommunicationHandler object at 0x7f3149dd9210>, <__main__.CommunicationHandler object at 0x7f3149dd1490>}
Traceback (most recent call last):
  File "/home/firefly/annat/kth/kurser/åk3/mvk13/repos/playhouse-web/src/config.py", line 286, in post
    manager.load_game()
  File "/home/firefly/annat/kth/kurser/åk3/mvk13/repos/playhouse-web/src/manager.py", line 38, in load_game
    game.destroy()
  File "/home/firefly/annat/kth/kurser/åk3/mvk13/repos/playhouse-web/src/lightgames.py", line 212, in destroy
    send_msg(h, {'message':"The game got destroyed!"})
  File "/home/firefly/annat/kth/kurser/åk3/mvk13/repos/playhouse-web/src/lightgames.py", line 31, in send_msg
    handler.write_message(tornado.escape.json_encode(msg))
  File "/usr/lib/python3.3/site-packages/tornado/websocket.py", line 178, in write_message
    raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError
FireyFly commented 10 years ago

Via Zetro on IRC: the issue is that connections in lightgames.Game is static, which it of course shouldn't be. This is a fault in my understanding of static vs. instance variables in Python. Will push a fix soon.