tornado ioloop current和instance的一些区别


import tornado.ioloop

# 此时_current没有instance
print dir(tornado.ioloop.IOLoop._current)

# 通过instance IOLoop() 会设置当前_current instance
a = tornado.ioloop.IOLoop.current()
print id(a)

print dir(tornado.ioloop.IOLoop._current)
# 直接获取当前线程初始化了的_current.instance
b = tornado.ioloop.IOLoop.current()
print id(b)


thread1
a = IOLoop()
b = a.current()
thread2
a1 = IOLoop()
b2 = a1.current()

th1 th2 分别拥有独立的ioloop

thread1
a = IOLoop.instance()
thread2
a1 = IOLoop.instance()

a a1 是一样的ioloop

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM