Skip to content

Commit 365295a

Browse files
committed
[tornado] add result to the handler.response event
1 parent fec2523 commit 365295a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ioc/extra/tornado/handler.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,12 @@ def dispatch(self):
110110

111111
# the dispatch is flagged as asynchronous by default so we make sure the finish method will be called
112112
# unless the result of the callback is a Future
113-
114113
if isinstance(result, Future):
115114
IOLoop.current().add_future(result, self.finish)
116115
return
117116

118117
if not self.is_finish():
119-
self.finish()
118+
self.finish(result=result)
120119

121120
def prepare(self):
122121
self.event_dispatcher.dispatch('handler.request', {
@@ -125,9 +124,15 @@ def prepare(self):
125124
})
126125

127126
def finish(self, *args, **kwargs):
127+
128+
result = None
129+
if 'result' in kwargs:
130+
result = kwargs['result']
131+
128132
self.event_dispatcher.dispatch('handler.response', {
129133
'request_handler': self,
130134
'request': self.request,
135+
'result': result
131136
})
132137

133138
super(RouterHandler, self).finish()

0 commit comments

Comments
 (0)