class TOLoop:@staticmethoddef instance():"""Returns a global `IOLoop` instance.Most applications have a single, global `IOLoop` running on themain thread. Use this method to get this instance fromanother thread. To get the current thread‘s `IOLoop`, use `current()`."""if not hasattr(IOLoop, "_instance"): //避免无意义的锁定, 因为大部分调用时只是简单的返回已经创建的_instancewith IOLoop._instance_lock:if not hasattr(IOLoop, "_instance"):# New instance after double checkIOLoop._instance = IOLoop()return IOLoop._instance
tornado singleton单例模式,布布扣,bubuko.com
原文:http://blog.csdn.net/qq550764107/article/details/21299245