DIRACSingleton

mod:DIRACSingleton
synopsis:metaclass singleton implementation

metaclass singleton implementation

class DIRAC.Core.Utilities.DIRACSingleton.DIRACSingleton(name, bases, dic)

Bases: type

Simple singleton pattern using metaclass

If you want make your class a singleton, just set its __metaclass__ to DIRACSingleton, i.e.:

from DIRAC.Core.Utilities.DIRACSingleton import DIRACSingleton
class CheesShop( object ):
  __metaclass__ = DIRACSingleton
  ...
__init__(name, bases, dic)

c’tor

Parameters:
  • cls – class def
  • name – class name (becomes __name__ attr)
  • bases – tuple of parent class defs (becomes __bases__ attr)
  • dic – definition dict for class body (becomes __dict__ attr)
mro() → list

return a type’s method resolution order