WRITE = _EPOLLOUT
ERROR = _EPOLLERR | _EPOLLHUP
+ # Global lock for creating global IOLoop instance
+ _instance_lock = threading.Lock()
+
def __init__(self, impl=None):
self._impl = impl or _poll()
if hasattr(self._impl, 'fileno'):
self.io_loop = io_loop or IOLoop.instance()
"""
if not hasattr(IOLoop, "_instance"):
- IOLoop._instance = IOLoop()
+ with IOLoop._instance_lock:
+ if not hasattr(IOLoop, "_instance"):
+ # New instance after double check
+ IOLoop._instance = IOLoop()
return IOLoop._instance
@staticmethod