Skip to content

Instantly share code, notes, and snippets.

View sathishbabu96's full-sized avatar

S Sathish Babu sathishbabu96

View GitHub Profile
@werediver
werediver / singleton.py
Created December 28, 2012 09:51
A thread safe implementation of singleton pattern in Python. Based on tornado.ioloop.IOLoop.instance() approach.
import threading
# Based on tornado.ioloop.IOLoop.instance() approach.
# See https://github.com/facebook/tornado
class SingletonMixin(object):
__singleton_lock = threading.Lock()
__singleton_instance = None
@classmethod