コード例 #1
0
 def subscribe_to_channel(self, channel):
     if channel in self.subscriptions:
         return self.subscriptions[channel]
     else:
         subject = Subject()
         # monkeypatch Subject to unsubscribe pubsub on observable
         # subscription.dispose()
         subject.observers = SubjectObserversWrapper(self, channel)
         self.subscriptions[channel] = subject
         return subject
コード例 #2
0
 def subscribe_to_channel(self, channel):
     if channel in self.subscriptions:
         return self.subscriptions[channel]
     else:
         self.pubsub.subscribe(channel)
         subject = Subject()
         # monkeypatch Subject to unsubscribe pubsub on observable
         # subscription.dispose()
         subject.observers = SubjectObserversWrapper(self, channel)
         self.subscriptions[channel] = subject
         if not self.greenlet:
             self.greenlet = gevent.spawn(self._wait_and_get_messages)
         return subject