Example #1
0
def timeoutAbsolute(self, dueTime, other=None, scheduler=Scheduler.timeBasedOperation):
  assert isinstance(self, Observable)
  assert isinstance(scheduler, Scheduler)

  if other == None:
    other = Observable.throw(TimeoutException())

  assert isinstance(other, Observable)

  return TimeoutAbsolute(self, dueTime, other, scheduler)
Example #2
0
def timeoutIndividual(self, durationSelector, firstTimeout=None, other=None):
  assert isinstance(self, Observable)

  if firstTimeout == None:
    firstTimeout = Observable.never()
  if other == None:
    other = Observable.throw(TimeoutException())

  assert isinstance(firstTimeout, Observable)
  assert isinstance(other, Observable)

  return TimeoutObservable(self, firstTimeout, durationSelector, other)
Example #3
0
    def run(self):
      source = None
      disposable = Disposable.empty()

      try:
        resource = self.parent.resourceFactory()
        if resource != None:
          disposable = resource

        source = self.parent.observableFactory(resource)
      except Exception as e:
        return CompositeDisposable(Observable.throw(e).subscribeSafe(self), disposable)

      return CompositeDisposable(source.subscribeSafe(self), disposable)
Example #4
0
        def run(self):
            source = None
            disposable = Disposable.empty()

            try:
                resource = self.parent.resourceFactory()
                if resource != None:
                    disposable = resource

                source = self.parent.observableFactory(resource)
            except Exception as e:
                return CompositeDisposable(
                    Observable.throw(e).subscribeSafe(self), disposable)

            return CompositeDisposable(source.subscribeSafe(self), disposable)
Example #5
0
    def start_async(cls, function_async):
        """Invokes the asynchronous function, surfacing the result through an
        observable sequence.

        Keyword arguments:
        function_async -- {Function} Asynchronous function which returns a
            Future to run.

        Returns {Observable} An observable sequence exposing the function's
        result value, or an exception."""

        try:
            future = function_async()
        except Exception as ex:
            return Observable.throw(ex)

        return Observable.from_future(future)
Example #6
0
    def start_async(cls, function_async):
        """Invokes the asynchronous function, surfacing the result through an
        observable sequence.

        Keyword arguments:
        function_async -- {Function} Asynchronous function which returns a
            Future to run.

        Returns {Observable} An observable sequence exposing the function's
        result value, or an exception."""

        try:
            future = function_async()
        except Exception as ex:
            return Observable.throw(ex)

        return Observable.from_future(future)