code: def locked(func):
      """Decorator which locks self.lock."""
  
      def nested(self, *args, **kwargs):
          self.lock.acquire()
          try:
              return func(self, *args, **kwargs)
          finally:
              self.lock.release()
  
      return nested
  
imports: import logging
  import select
  import socket
  import struct
  import threading
  from collections import deque
  from six.moves import queue
  from thrift.transport import TTransport
  from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory
label_desc: Use image node_id 1 for calling a global function with example usage: locked(func) and returns: nested, func