text: import contextlib
  
  
  def callback(*args, **kwds):
      print('closing callback({}, {})'.format(args, kwds))
  
  
  try:
      with contextlib.ExitStack() as stack:
          stack.callback(callback, 'arg1', 'arg2')
          stack.callback(callback, arg3='val3')
          raise RuntimeError('thrown error')
  except RuntimeError as err:
      print('ERROR: {}'.format(err))
  