tornado有TypeError(\"Unsupported timeout %r\" % timeout)报错是怎么
2024-05-16

import tornado.ioloop

def handle_timeout():
print("timeout occurred")

def start_timeout(timeout):
if not isinstance(timeout, (int,float)):
raise ValueError("timeout must be a number")
tornado.ioloop.IOLoop.current().call_later(timeout, handle_timeout)

try:
start_timeout(10) # this will work
start_timeout("10") # this will raise ValueError
except ValueError as e:
print(str(e))
登录后复制