python make _Timeout(tornado.ioloop)可见
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python make _Timeout(tornado.ioloop)可见相关的知识,希望对你有一定的参考价值。
import datetime
import random
import time
import tornado.ioloop
import tornado.web
TIME = "%Y-%m-%d %H:%M:%S"
# patch
tornado.ioloop._Timeout.__repr__ = lambda self: "{} ({}) {}".format(
time.strftime(TIME, time.localtime(self.deadline)),
self.deadline,
self.callback and self.callback.__doc__,
)
io_loop = tornado.ioloop.IOLoop.instance()
f = lambda: print(time.time(), time.strftime(TIME))
class MainHandler(tornado.web.RequestHandler):
def get(self):
t = time.time()
io_loop.add_timeout(
datetime.timedelta(seconds=random.random()*60),
f).callback.__doc__ = "XXX, {} ({})".format(
time.strftime(TIME, time.localtime(t)), t)
self.set_header("Content-Type", "text/plain")
self.write("\n".join(map(repr, sorted(io_loop._timeouts))))
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
import tornado.options
tornado.options.parse_command_line()
application.listen(1024)
io_loop.start()
以上是关于python make _Timeout(tornado.ioloop)可见的主要内容,如果未能解决你的问题,请参考以下文章
使用 boost::python::make_function 设置 __name__ 属性
4.11 timeout
Python serial
python_如何修改装饰器中参数?
在Linux下安装Python执行make命令时报错“Failed to build these modules: _ctypes“
rehat 6安装python 3.7.4报错ModuleNotFoundError: No module named '_ctypes' make: *** [install] Er