def try_serialize_handler(handler):
  if (isinstance(handler, types.InstanceType) or
      (isinstance(handler, object) and
       not inspect.isfunction(handler) and
       not inspect.ismethod(handler)) and
      hasattr(handler, "__call__")):
    return pickle.dumps(handler)
  return None
Returns:
dataset/ETHPy150Open GoogleCloudPlatform/python-compat-runtime/appengine-compat/exported_appengine_sdk/google/appengine/ext/mapreduce/util.py/try_serialize_handler--crossover with--dataset/ETHPy150Open meraki-analytics/cassiopeia/cassiopeia/type/core/match.py/Event.ward