Skip to content

Commit

Permalink
[fix] tornado 4.1 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mosquito committed Mar 1, 2015
1 parent 9943069 commit d9775a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from distutils.core import setup


__version__ = '0.1.10'
__version__ = '0.1.11pre'
__author__ = 'Dmitry Orlov <[email protected]>'


Expand Down
8 changes: 7 additions & 1 deletion wsrpc/websocket/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import tornado.websocket
import tornado.ioloop
import tornado.escape
import tornado.gen
import types
from functools import partial
from time import sleep
Expand Down Expand Up @@ -43,7 +44,7 @@ class WebSocket(tornado.websocket.WebSocketHandler):

def _execute(self, transforms, *args, **kwargs):
if self.authorize():
super(WebSocket, self)._execute(transforms, *args, **kwargs)
return super(WebSocket, self)._execute(transforms, *args, **kwargs)
else:
self.stream.write(tornado.escape.utf8(
"HTTP/1.1 403 Forbidden\r\n\r\n"
Expand Down Expand Up @@ -290,6 +291,11 @@ def responder(data):
log.error(repr(data))
self.locks.remove(serial)
return self._send(data=repr(data), serial=serial, type='error')
elif isinstance(data, tornado.gen.Future):
if data.running():
data.add_done_callback(response)
else:
return responder(data.result())
else:
self.locks.remove(serial)
return self._send(data=data, serial=serial, type='callback')
Expand Down

0 comments on commit d9775a2

Please sign in to comment.