code: def in_generator(self, generator):
          
          previous_generator = self._current_generator
          try:
              self._current_generator = generator
              yield
          finally:
              self._current_generator = previous_generator
docs: Context manager: set the given generator as the current generator.