example client execution time

Asked by nside

Thanks for the latest release (thrift support is awesome)
Just one question: I ran the example client using a local rabbitmq server and it ran in 3.5seconds. Is it normal that it takes so long?
Here's my client command:
nside@nside-ubuntu:~/d/python-txamqp-0.2.1/src/examples$ time python client.py localhost 5672 / guest guest ../specs/standard/amqp0-8.xml
Ping received
Got results to add()
3
Got an error
integer division or modulo by zero
Got results to calculate()
5
Got results to calculate()
-1
Got results to calculate()
6
Got results to calculate()
0

real 0m3.519s
user 0m0.452s
sys 0m0.048s

Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
txAMQP Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Esteve Fernandez (esteve) said :
#1

Good to hear you like Thrift + AMQP :-)

As for the question, the reason is that the server waits 3 seconds before it sends a response to a calculate() call:

---- server.py ----

    def _dispatchWork(self, w):
        # Just assume that it may take a long time
        results = self.operations[w.op](w.num1, w.num2)
        d = defer.Deferred()
        reactor.callLater(3, d.callback, results)
        return d

---- server.py ----

Just change 3 to 0. I wanted to show that, thanks to Twisted, you can return deferreds. For example, imagine the case where you are using Twisted's adbapi for querying a database.

Also, keep in mind that the client has to prepare the underlying transport (see the prepareClient function) before it can make any remote call. If you foresee that you'll create lots of clients in your project, I would suggest you to pre-create them and use a pool to save some time. Anyway, I'm sure there's still a lot of things to optimize in txAMQP.

Thanks for you feedback!

Revision history for this message
Esteve Fernandez (esteve) said :
#2

Marking this question as solved.