下面是我的基本处理程序。我只想提供一个图像,在请求完成后,我想写到 redis 但是当我运行下面的代码时,on_finish 没有被调用。
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)