code: def _io_loop_call(has_result, f, *kargs, **kwargs):
      class Result:
          def __init__(self, val=None):
              self.val = val
  
      def wrapper(f, r, *kargs, **kwargs):
          try:
              r.val = f(*kargs, **kwargs)
              ZmqWrapper._ioloop_block.set()
          except:
              logging.exception("Error in call scheduled in ioloop")
  
      # We will add callback in IO Loop and then wait for that
      # call back to be completed
      # If result is expected then we wait other wise fire and forget
      if has_result:
          if not ZmqWrapper._ioloop_block.is_set():
              # TODO: better way to raise this error?
              print(
                  "Previous blocking call on IOLoop is not yet complete!"
              )
          ZmqWrapper._ioloop_block.clear()
          r = Result()
          f_wrapped = functools.partial(wrapper, f, r, *kargs, **kwargs)
          ZmqWrapper._ioloop.add_callback(f_wrapped)
          utils.debug_log("Waiting for call on ioloop", f, verbosity=5)
          ZmqWrapper._ioloop_block.wait()
          utils.debug_log("Call on ioloop done", f, verbosity=5)
          return r.val
      else:
          f_wrapped = functools.partial(f, *kargs, **kwargs)
          ZmqWrapper._ioloop.add_callback(f_wrapped)
  
file_path: tensorwatch/tensorwatch/zmq_wrapper.py
imports: import zmq
  import errno
  import pickle
  from zmq.eventloop import ioloop, zmqstream
  import zmq.utils.monitor
  import functools, sys, logging
  from threading import Thread, Event
  from .None import utils
  import weakref, logging
label_desc: Use image node_id 5 for calling the ZmqWrapper obj's underlying member method code with example usage: obj._io_loop_call(has_result, f) and returns: r