Below is my basic handler. I just want to server an image and after the requeste is complete, I want to write to redis but when I run the below code, the on_finish is not called.
import cyclone.web
import cyclone.redis
from twisted.internet import defer
from twisted.internet import reactor
tt = cyclone.redis.lazyConnectionPool()
class PixelHandler(cyclone.web.RequestHandler):
@cyclone.web.asynchronous
def get(self):
qs = qs_decode(self.request.query)
self.set_header('Content-Type', 'image/gif')
self.write(pixel)
redisPixelWrite(remote_ip)
#self.finish()
def on_finish(self):
t = yield tt.multi()
yield t.set('key', 'value')
r = yield t.commit()
print "commit=", repr(r)