我需要在我的web應用程序中使用異步子進程鎖。 我寫入下一個代碼:什麼是平均收益率無(tornado.gen.moment)
r = redis.Redis('localhost')
pipe = r.pipeline()
is_locked = False
while not is_locked:
try:
pipe.watch(lock_name)
current_locked = int(pipe.get(lock_name))
if current_locked == 0:
pipe.multi()
pipe.incr(lock_name)
pipe.execute()
is_locked = True
else:
yield None
except redis.WatchError:
yield None
return True
在文檔writen該tornado.gen.moment(yield None
因爲版本4.5)是可被產生,以允許IOLoop爲一次迭代運行的特殊對象。怎麼運行的?它是否與其他Feature對象(來自其他請求)的下一次迭代?是否正確yield None
用法?
的cource,它在一個功能裝飾tornado.gen.coroutine – COUNTERKILL