# Path: rx/disposable.py
# class Disposable(object):
#   """Represents a disposable object"""
# 
#   def dispose(self):
#     pass
# 
#   def __enter__(self):
#     return self
# 
#   def __exit__(self, exc_type, exc_value, traceback):
#     self.dispose()
# 
#   @staticmethod
#   def create(action):
#     return AnonymouseDisposable(action)
# 
#   @staticmethod
#   def empty():
#     return disposableEmpty
# 
# Path: rx/observable.py
# class Producer(Observable):
#   """Base class for implementation of query operators, providing
#   performance benefits over the use of Observable.Create"""
# 
#   def subscribeCore(self, observer):
#     return self.subscribeRaw(observer, True)
# 
#   def subscribeRaw(self, observer, enableSafequard):
#     sink = SingleAssignmentDisposable()
#     subscription = SingleAssignmentDisposable()
# 
#     d = CompositeDisposable(sink, subscription)
# 
#     if enableSafequard:
#       observer = AutoDetachObserver(observer, d)
# 
#     def assignSink(s):
#       sink.disposable = s
# 
#     def scheduled():
#       subscription.disposable = self.run(observer, subscription, assignSink)
#       return Disposable.empty()
# 
#     if Scheduler.currentThread.isScheduleRequired():
#       Scheduler.currentThread.schedule(scheduled)
#     else:
#       scheduled()
# 
#     return d
# 
#   def run(self, observer, cancel, setSink):
#     raise NotImplementedError()


from rx.disposable import Disposable
from rx.observable import Producer
import rx.linq.sink
      return self.parent.scheduler.scheduleWithState(
        self.parent.initialState,
        self.invokeRec
      )

    def invokeRec(self, scheduler, state):
      time = 0

      if self.hasResult:
        self.observer.onNext(self.result)

      try:
        if self.first:
          self.first = False
        else:
          state = self.parent.iterate(state)

        self.hasResult = self.parent.condition(state)

        if self.hasResult:
          self.result = self.parent.resultSelector(state)
          time = self.parent.timeSelector(state)
      except Exception as e:
        self.observer.onError(e)
        self.dispose()
        return Disposable.empty()

      if not self.hasResult:
        self.observer.onCompleted()
        self.dispose()

# Path: rx/disposable.py
# class Disposable(object):
#   """Represents a disposable object"""
# 
#   def dispose(self):
#     pass
# 
#   def __enter__(self):
#     return self
# 
#   def __exit__(self, exc_type, exc_value, traceback):
#     self.dispose()
# 
#   @staticmethod
#   def create(action):
#     return AnonymouseDisposable(action)
# 
#   @staticmethod
#   def empty():
#     return disposableEmpty
# 
# Path: rx/observable.py
# class Producer(Observable):
#   """Base class for implementation of query operators, providing
#   performance benefits over the use of Observable.Create"""
# 
#   def subscribeCore(self, observer):
#     return self.subscribeRaw(observer, True)
# 
#   def subscribeRaw(self, observer, enableSafequard):
#     sink = SingleAssignmentDisposable()
#     subscription = SingleAssignmentDisposable()
# 
#     d = CompositeDisposable(sink, subscription)
# 
#     if enableSafequard:
#       observer = AutoDetachObserver(observer, d)
# 
#     def assignSink(s):
#       sink.disposable = s
# 
#     def scheduled():
#       subscription.disposable = self.run(observer, subscription, assignSink)
#       return Disposable.empty()
# 
#     if Scheduler.currentThread.isScheduleRequired():
#       Scheduler.currentThread.schedule(scheduled)
#     else:
#       scheduled()
# 
#     return d
# 
#   def run(self, observer, cancel, setSink):
#     raise NotImplementedError()


# Path: rx/linq/generate.py
from rx.disposable import Disposable
from rx.observable import Producer
import rx.linq.sink

      return self.parent.scheduler.scheduleWithState(
        self.parent.initialState,
        self.invokeRec
      )

    def invokeRec(self, scheduler, state):
      time = 0

      if self.hasResult:
        self.observer.onNext(self.result)

      try:
        if self.first:
          self.first = False
        else:
          state = self.parent.iterate(state)

        self.hasResult = self.parent.condition(state)

        if self.hasResult:
          self.result = self.parent.resultSelector(state)
          time = self.parent.timeSelector(state)
      except Exception as e:
        self.observer.onError(e)
        self.dispose()
        return Disposable.empty()

      if not self.hasResult:
        self.observer.onCompleted()
        self.dispose()

        return Disposable.empty()