[Twisted-Python] pyactivemq interfering with Twisted?

Valentino Volonghi dialtone at gmail.com
Tue Mar 18 21:35:42 MDT 2008


On Wed, Mar 19, 2008 at 2:49 AM, Brian Baquiran <brianbaquiran at gmail.com> wrote:
> The API does not block when using an async message listener as I'm doing.
> Here's some example pyactivemq code that shows how an asynchronous message
> listener is registered:
>  http://pyactivemq.googlecode.com/svn/trunk/src/examples/asynclistener.py

This API actually blocks.

Just by looking at:
   conn = f.createConnection()

Which means that you can create a connection and immediately get the result.
This is blocking by any relevant definition of blocking.

Judging by the API the only difference between sync and async seems to
be related
to the type of producer involved. A Push producer is generally
considered async and
a pull producer is sync.

Looking further in the API of ActiveMQ-CPP, even though I'm not too
good with C++,
I can easily spot lines like the following:

Response* response = transport->request( &cmd );

which to me appears as totally synchronous and thus blocking,
a non blocking API would have been more like:

transport->request(&cmd, &onMessage);

The transport itself is implemented in the following way:

        // Start the polling thread.
        thread = new Thread( this );
        thread->start();

and its run method contains:

    try{

        while( !closed ){

            // Read the next command from the input stream.
            Command* command = reader->readCommand();

            // Notify the listener.
            fire( command );
        }

    }

Considering all of this you should probably use this from deferToThread.

-- 
Valentino Volonghi aka Dialtone
Now running MacOS X 10.5
Home Page: http://www.twisted.it




More information about the Twisted-Python mailing list