Github user ted-ross commented on a diff in the pull request:

    https://github.com/apache/qpid-dispatch/pull/165#discussion_r121764581
  
    --- Diff: tests/system_tests_three_routers.py ---
    @@ -335,36 +417,124 @@ def on_start ( self, event ):
             self.client_receiver   = 
event.container.create_receiver(self.client_connection, None, dynamic=True)
     
     
    +    def on_sendable ( self, event ):
    +        if event.sender == self.sender :
    +            while event.sender.credit > 0 and self.n_sent < 
self.n_expected:
    +                # We send to server, and tell it how to reply to the 
client.
    +                reply_to_addr = self.client_receiver.remote_source.address
     
    -    def on_sendable(self, event):
    -        while event.sender.credit > 0 and self.n_sent < self.n_expected:
    -            # We send to server, and tell it how to reply to the client.
    -            reply_to_addr = self.client_receiver.remote_source.address
    -
    -            request = Message ( body=self.n_sent,
    -                                address=self.dest,
    -                                reply_to = reply_to_addr )
    -            event.sender.send ( request )
    -            self.n_sent += 1
    +                request = Message ( body=self.n_sent,
    +                                    address=self.dest,
    +                                    reply_to = reply_to_addr )
    +                event.sender.send ( request )
    +                self.n_sent += 1
     
     
    -    def on_message(self, event):
    +    def on_message ( self, event ):
             # Server gets a request and responds to
             # the address that is embedded in the message.
             if event.receiver == self.server_receiver :
    -            self.server_sender.send ( 
Message(address=event.message.reply_to,
    -                                      body="Reply hazy, try again later.") 
)
    +            # pdb.set_trace()
                 self.received_by_server += 1
    +            msg = Message(address=event.message.reply_to, body="Reply 
hazy, try again later.")
    +            self.server_sender.send ( msg )
     
             # Client gets a response and counts it.
             elif event.receiver == self.client_receiver :
                 self.received_by_client += 1
                 if self.received_by_client == self.n_expected:
    -                self.timer.cancel()
    -                self.server_receiver.close()
    -                self.client_receiver.close()
    -                self.client_connection.close()
    -                self.server_connection.close()
    +                self.shutdown ( )
    +
    +
    +    def run(self):
    +        Container(self).run()
    +
    +
    +
    +
    +
    +class LinkRoute ( MessagingHandler ):
    +
    +    """
    +        Set up and use a link-route, to send a message this way:
    +            receiver <--- A <--- B <--- C <--- sender
    +    """
    +
    +    def __init__ ( self, addr_listening_for_route_container, 
linkroute_prefix, qdstat_address, send_address ):
    +        super(LinkRoute, self).__init__(prefetch=0)
    +        self.addr_listening_for_route_container = 
addr_listening_for_route_container
    +        self.send_address = send_address
    +        self.linkroute_prefix = linkroute_prefix
    +        self.qdstat_address = qdstat_address
    +        self.error      = None
    +        self.send_connection = None
    +        self.recv_connection = None
    +        self.false_statement = "This is not the message you are looking 
for."
    +
    +
    +    def timeout(self):
    +        self.error = "Timeout Expired"
    +        self.shutdown ( )
    +
    +
    +    def shutdown ( self ) :
    +        self.recv_connection.close()
    +        self.send_connection.close()
    +        self.timer.cancel()
    +        self.timer = None
    +
    +
    +    def on_start(self, event):
    +        # Iff this timer expires, the test fails.
    +        self.timer = event.reactor.schedule ( 5, Timeout(self) )
    +
    +        # Create the receiver only at start time.
    +        # Sender-creation has to wait until we know that the address is 
available.
    +        self.recv_connection = event.container.connect ( 
self.addr_listening_for_route_container )
    +        self.receiver = event.container.create_receiver ( 
self.recv_connection, None, dynamic=True )
    +
    +
    +    def on_link_opening ( self, event ):
    +        if event.receiver:
    +            event.receiver.flow(1)
    +
    +
    +    def on_connection_remote_open ( self, event ):
    --- End diff --
    
    Doing this blocking, synchronous operation in a reactive event handler is 
not a good practice.  The reactor is prevented from maintaining its connections 
for the entire duration of this function.
    There is an example in system_tests_multi_tenancy (LinkRouteTest) that does 
what's needed to wait for the link-route to propagate within the reactive 
framework.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to