class_docstr: Metrics manager and batch writer 
class_docstr_tok: ["Metrics","manager","and","batch","writer"]
docstr: A wrapper for the async callback for handling common errors 
docstr_tok: ["A","wrapper","for","the","async","callback","for","handling","common","errors"]
code: def _callback_wrapper(self, callback, res):
      """A wrapper for the async callback for handling common errors"""
      if not res:
          # no result yet
          return
      elif isinstance(res, Exception):
          # error
          self.log.error("Error trying to send metrics: %s" % str(res))
      elif not res.ok():
          # bad result, log error
          self.log.error("Failed reporting metrics: %s" % str(res.meta))
      # call callback, even if we received an error
      if callback:
          callback(res)
  
imports: import json
  import os
  from functools import partial
  from logging import warning
  from multiprocessing.pool import ThreadPool
  from time import time
  from pathlib2 import Path
  from ...backend_api import Session
  from ...backend_api.services import events
  from ..base import InterfaceBase
  from ...config import config, deferred_config
  from ...debugging import get_logger
  from ...storage.helper import StorageHelper
  from .events import MetricsEventAdapter
  from ...utilities.process.mp import SingletonLock
label_desc: Use image node_id 8 for calling the Metrics obj's underlying member method code with example usage: obj._callback_wrapper(callback, res) without return types