tornado的IOLoop.instance()方法和IOLoop.current()方法区别

在使用tornado时,经常有人疑惑IOLoop.current()方法和IOLoop.instance()方法的区别是什么。

IOLoop.current() 

返回当前线程的IOLoop,如果IOLoop当前正在运行或已被make_current标记为当前,则返回该实例。

如果没有当前IOLoop,则调用IOLoop.instance()方法创建一个IOLoop的实例返回。

IOLoop.instance()

返回全局 IOLoop实例。

在tornado 5.0之后的版本,instance()已经成为current()的别称。

猜你喜欢

转载自www.cnblogs.com/lucky-heng/p/10152995.html