code: def _compile_proto(full_path, dest):
      'Helper to compile protobuf files'
      proto_path = os.path.dirname(full_path)
      protoc_args = [find_protoc(),
                     '--python_out={}'.format(dest),
                     '--proto_path={}'.format(proto_path),
                     full_path]
      proc = subprocess.Popen(protoc_args, stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
      try:
          outs, errs = proc.communicate(timeout=5)
      except subprocess.TimeoutExpired:
          proc.kill()
          outs, errs = proc.communicate()
          return False
  
      if proc.returncode != 0:
          msg = 'Failed compiling "{}": \n\nstderr: {}\nstdout: {}'.format(
              full_path, errs.decode('utf-8'), outs.decode('utf-8'))
          raise BadProtobuf(msg)
  
      return Truf _compile_proto(full_path, dest):
      'Helper to compile protobuf files'
      proto_path = os.path.dirname(full_path)
      protoc_args = [find_protoc(),
                     '--python_out={}'.format(dest),
                     '--proto_path={}'.format(proto_path),
                     full_path]
      proc = subprocess.Popen(protoc_args, stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
      try:
          outs, errs = proc.communicate(timeout=5)
      except subprocess.TimeoutExpired:
          proc.kill()
          outs, errs = proc.communicate()
          return False
  
      if proc.returncode != 0:
          msg = 'Failed compiling "{}": \n\nstderr: {}\nstdout: {}'.format(
              full_path, errs.decode('utf-8'), outs.decode('utf-8'))
          raise BadProtobuf(msg)
  
      return True
docs: Helper to compile protobuf files