예제 #1
0
 def __init__(self, loop=None):
     Subscriber.__init__(self)
     self._result_vector = []
     if loop is not None:
         self._timestamp_vector = []
         self._start_timestamp = loop.time()
     self._loop = loop
예제 #2
0
 def subscribe(self, subscriber: Subscriber,
               prepend: bool = False) -> SubscriptionDisposable:
     disposable = Publisher.subscribe(self, subscriber, prepend)
     if self._interval is None:
         try:
             result = self._poll_func()
             subscriber.emit(result, who=self)
         except Exception:  # pylint: disable=broad-except
             self._error_callback(*sys.exc_info())
     elif self._call_later_handler is None:
         self._poll_callback()
     return disposable
예제 #3
0
    def subscribe(self,
                  subscriber: Subscriber,
                  prepend: bool = False) -> SubscriptionDisposable:
        disposable = Publisher.subscribe(self, subscriber, prepend)

        old_state = self._state  # to check if .emit was called

        if len(self._subscriptions) == 1:  # if this was the first subscription
            self._publisher.subscribe(self._emit_sink)

        try:
            value = self._publisher.get()
        except ValueError:
            if self._state is not NONE:
                subscriber.emit(self._state, who=self)
        else:
            if len(self._subscriptions) > 1 or old_state == self._state:
                subscriber.emit(value, who=self)

        return disposable
예제 #4
0
    def subscribe(self,
                  subscriber: Subscriber,
                  prepend: bool = False) -> SubscriptionDisposable:
        disposable = Publisher.subscribe(self, subscriber, prepend)

        if self._subject is not None:
            if not isinstance(self._subject, Publisher):
                raise TypeError('Topic %r has to be a Publisher when using'
                                ' .subscribe()' % self._path)

            if len(self._subscriptions) == 1:
                self._subject.subscribe(self)
            else:
                try:
                    value = self._subject.get()
                except ValueError:
                    pass
                else:
                    subscriber.emit(value, who=self)

        return disposable
예제 #5
0
 def __init__(self, init):
     StatefulPublisher.__init__(self, init)
     Subscriber.__init__(self)
예제 #6
0
 def __init__(self):
     Publisher.__init__(self)
     Subscriber.__init__(self)
예제 #7
0
 def __init__(self, init=NONE):
     Publisher.__init__(self, init)
     Subscriber.__init__(self)
예제 #8
0
 def __init__(self, *publishers: Publisher) -> None:
     Publisher.__init__(self)
     Subscriber.__init__(self)
     self._orginators = publishers
     self.add_dependencies(*publishers)
예제 #9
0
 def __init__(self, publisher: Publisher) -> None:
     Publisher.__init__(self)
     Subscriber.__init__(self)
     self._orginator = publisher
     self.add_dependencies(publisher)
예제 #10
0
 def __init__(self) -> None:
     Publisher.__init__(self)
     Subscriber.__init__(self)
     self._originator = None  # type: typing.Optional[Publisher]