old_contents: from functools import wraps
  
  import gevent
  from greenlet import GreenletExit
  
  
  def exit_on_error(func):
      @wraps(func)
      def wrapper(*args, **kw):
          try:
              func(*args, **kw)
          except gevent.get_hub().SYSTEM_ERROR:
              raise
          except GreenletExit:
              raise
          except BaseException as err:
              raise UnhandledError(err) from err
      return wrapper
  
  
  def wait_for_one_task_to_complete(pool):
      if not pool:
          raise ValueError("pool is empty")
      with gevent.iwait(pool) as completed:
          next(completed)
  
  
  class UnhandledError(SystemExit):
      pass
  
new_contents: from functools import wraps
  
  import gevent
  from greenlet import GreenletExit
  
  
  def exit_on_error(func):
      @wraps(func)
      def wrapper(*args, **kw):
          try:
              return func(*args, **kw)
          except gevent.get_hub().SYSTEM_ERROR:
              raise
          except GreenletExit:
              raise
          except BaseException as err:
              raise UnhandledError(err) from err
      return wrapper
  
  
  def wait_for_one_task_to_complete(pool):
      if not pool:
          raise ValueError("pool is empty")
      with gevent.iwait(pool) as completed:
          next(completed)
  
  
  class UnhandledError(SystemExit):
      pass
  
subject: Fix exit_on_error in case of return value