예제 #1
0
    def send(self,
             message,
             timeout=None,
             tracker_queue=None,
             on_delivery=None):
        """
        Send a message.

        Blocks until credit is available and the message can be sent.
        Use :meth:`Tracker.await_delivery()` to block until the remote peer acknowledges the message.

        If set, a tracker for a completed delivery is placed on `tracker_queue` after the delivery is acknowledged.

        If set, `on_delivery(tracker)` is called after the delivery is acknowledged.
        It is called on another thread, not the main API thread.
        Users must take care to use thread-safe code in the callback.

        :rtype: Tracker
        """

        self._message_queue.put((message, tracker_queue, on_delivery))

        event = _reactor.ApplicationEvent("message_enqueued",
                                          subject=self._proton_object)
        self.container._event_injector.trigger(event)

        return self._tracker_port.get()
예제 #2
0
    def __init__(self, container):
        self.container = container

        self.proton_object = None
        self.gambit_object_port = _ReturnPort()
        self.completed = _threading.Event()

        self.container._operations.put(self)
        self.container._event_injector.trigger(
            _reactor.ApplicationEvent("operation_enqueued"))
예제 #3
0
 def send_input(self, message):
     self.input_messages.appendleft(message)
     self.events.trigger(_reactor.ApplicationEvent("input"))
예제 #4
0
 def push_line(self, line):
     super(_InputThread, self).push_line(line)
     self.command.events.trigger(_reactor.ApplicationEvent("input"))
예제 #5
0
    def fire_object_update(self, obj):
        _log.info("Firing update for %s", obj)

        event = _reactor.ApplicationEvent("object_update", subject=obj)
        self.events.trigger(event)