code: def _locked(func):
      
      def _locking(self, *args, **kwargs):
          try:
              self.lock()
              return func(self, *args, **kwargs)
          finally:
              self.unlock()
      return _locking
docs: ! Decorator to automatically lock an AccessPort method.