old_contents: #!/usr/bin/python
  """
  @file singleton.py
  @author Woong Gyu La a.k.a Chris. <juhgiyo@gmail.com>
          <http://github.com/juhgiyo/pyserver>
  @date March 10, 2016
  @brief Singlton Interface
  @version 0.1
  
  @section LICENSE
  
  The MIT License (MIT)
  
  Copyright (c) 2016 Woong Gyu La <juhgiyo@gmail.com>
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
  
  @section DESCRIPTION
  
  Singlton Class.
  """
  import threading
  
  
  class Singleton:
      """
      A non-thread-safe helper class to ease implementing singletons.
      This should be used as a decorator -- not a metaclass -- to the
      class that should be a singleton.
  
      The decorated class can define one `__init__` function that
      takes only the `self` argument. Other than that, there are
      no restrictions that apply to the decorated class.
  
      To get the singleton instance, use the `instance` method. Trying
      to use `__call__` will result in a `TypeError` being raised.
  
      Limitations: The decorated class cannot be inherited from.
  
      """
  
      def __init__(self, decorated):
          self._decorated = decorated
          self.lock = threading.RLock()
  
      def instance(self):
          """
          Returns the singleton instance. Upon its first call, it creates a
          new instance of the decorated class and calls its `__init__` method.
          On all subsequent calls, the already created instance is returned.
  
          """
          with self.lock:
              try:
                  return self._instance
              except AttributeError:
                  # noinspection PyAttributeOutsideInit
                  self._instance = self._decorated()
                  return self._instance
  
      def __call__(self):
          raise TypeError('Singletons must be accessed through `instance()`.')
  
      def __instancecheck__(self, inst):
          return isinstance(inst, self._decorated)
  
new_contents: #!/usr/bin/python
  """
  @file singleton.py
  @author Woong Gyu La a.k.a Chris. <juhgiyo@gmail.com>
          <http://github.com/juhgiyo/pyserver>
  @date March 10, 2016
  @brief Singleton Interface
  @version 0.1
  
  @section LICENSE
  
  The MIT License (MIT)
  
  Copyright (c) 2016 Woong Gyu La <juhgiyo@gmail.com>
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
  
  @section DESCRIPTION
  
  Singleton Class.
  """
  import threading
  
  
  class Singleton:
      """
      A non-thread-safe helper class to ease implementing singletons.
      This should be used as a decorator -- not a metaclass -- to the
      class that should be a singleton.
  
      The decorated class can define one `__init__` function that
      takes only the `self` argument. Other than that, there are
      no restrictions that apply to the decorated class.
  
      To get the singleton instance, use the `instance` method. Trying
      to use `__call__` will result in a `TypeError` being raised.
  
      Limitations: The decorated class cannot be inherited from.
  
      """
  
      def __init__(self, decorated):
          self._decorated = decorated
          self.lock = threading.RLock()
  
      def instance(self):
          """
          Returns the singleton instance. Upon its first call, it creates a
          new instance of the decorated class and calls its `__init__` method.
          On all subsequent calls, the already created instance is returned.
  
          """
          with self.lock:
              try:
                  return self._instance
              except AttributeError:
                  # noinspection PyAttributeOutsideInit
                  self._instance = self._decorated()
                  return self._instance
  
      def __call__(self):
          raise TypeError('Singletons must be accessed through `instance()`.')
  
      def __instancecheck__(self, inst):
          return isinstance(inst, self._decorated)
  
subject: Update singleton.py