WSGI process as a WAMP client

#1

Hello,

Given the lack of async Python drivers for most databases in Python 3, I want to write a component doing db queries and make RPC calls to it.

I also want to code an configuration system which will signal all clients when a value has changed, using PUB/SUB.

One of my client is a WSGI process, coded using Werkzeug and Python 3.

Can I use it as a WAMP client ? If yes, how ? Cause I don’t what to do with the WAMP client main loop.

If no, is there an alternative ?

E.G : does a stateless HTTP transport for WAMP exists, using callbacks URI ? If no, how can I code that (or at least find the informations to do so) ?

My goal is to enventually have independant components that can run on their own for dev, then on deployment, to hook them on crossbar.io.

Cheers

0 Likes

#2

I’m completly ok with rewriting the WSGI component using a different technology if needed, such as tornado/cyclone. My only requirement is that I can use Python 3 to do so and that I’m not required to install compiled c extension (optional c accelerators are fine).

0 Likes

#3

Hello,

Given the lack of async Python drivers for most databases in Python 3, I

That's not a problem .. Twisted ADB will run code using blocking database drivers on a background thread pool:

https://twistedmatrix.com/documents/current/core/howto/rdbms.html

want to write a component doing db queries and make RPC calls to it.

I also want to code an configuration system which will signal all
clients when a value has changed, using PUB/SUB.

One of my client is a WSGI process, coded using Werkzeug and Python 3.

Can I use it as a WAMP client ? If yes, how ? Cause I don't what to do
with the WAMP client main loop.

In general, since WSGI is synchronous, I can't see how a fully-fledged WAMP client would be able to run within the WSGI based code.

While Crossbar.io can host/run WSGI components:

https://github.com/crossbario/crossbar/wiki/WSGI-Host-Service

you cannot directly mix WSGI with WAMP code.

Crossbar.io runs WSGI components on a background thread pool using Twisted Web WSGI container.

What you can do using that is call into the main thread

http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorThreads.callFromThread.html

which would allow you to do (unacknowledged) Publish, but none of the others (Call, Register or Subscribe).

If no, is there an alternative ?

E.G : does a stateless HTTP transport for WAMP exists, using callbacks
URI ? If no, how can I code that (or at least find the informations to
do so) ?

We have started a "HTTP long-poll" based transport once for WAMP .. mainly for browsers lacking WebSocket support.

However, if your goal is to run that under (synchronous) WSGI, that won't work as you expect: serving HTTP long-poll using a synchronous HTTP server framework (WSGI) will bring the server down quickly.

Keeping open 1000 long-poll connections on a classical WSGI server will occupy 1000 threads.

My goal is to enventually have independant components that can run on
their own for dev, then on deployment, to hook them on crossbar.io.

That's great!

But WSGI (PEP 3333) IMHO isn't the right substrate to base everything on .. in fact, WSGI is a dead end right now

https://groups.google.com/d/msg/python-tulip/Gs3bZ2AbS9o/WUp3ktn9UkoJ

···

Am 02.04.2014 10:52, schrieb Michel Desmoulin:

Cheers

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com
<mailto:autobahnws+...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#4

Twisted won’t run on Python 3 for now, so I’m going to look for an asyncio solution or something alike. If I fail, I’ll fallback on Python 2. Twisted will migrate eventually.

Thanks for saying aloud that the current WSGI spec is a dead end. I needed to hear that so I can look into alternatives.

···

On Wednesday, April 2, 2014 10:52:59 AM UTC+2, Michel Desmoulin wrote:

Hello,

Given the lack of async Python drivers for most databases in Python 3, I want to write a component doing db queries and make RPC calls to it.

I also want to code an configuration system which will signal all clients when a value has changed, using PUB/SUB.

One of my client is a WSGI process, coded using Werkzeug and Python 3.

Can I use it as a WAMP client ? If yes, how ? Cause I don’t what to do with the WAMP client main loop.

If no, is there an alternative ?

E.G : does a stateless HTTP transport for WAMP exists, using callbacks URI ? If no, how can I code that (or at least find the informations to do so) ?

My goal is to enventually have independant components that can run on their own for dev, then on deployment, to hook them on crossbar.io.

Cheers

0 Likes

#5

Michel,

Twisted won't run on Python 3 for now, so I'm going to look for an

Yes, Twisted does not yet fully support Python 3, but many things already work. In particular, Autobahn with _WebSocket_ stuff works.

asyncio solution or something alike. If I fail, I'll fallback on Python

Please note that while Autobahn|Python fully supports Python 2 and 3 and Twisted and asyncio for _WebSocket_, support for _WAMP_ is not yet there:

https://github.com/tavendo/AutobahnPython/issues/200

2. Twisted will migrate eventually.

Thanks for saying aloud that the current WSGI spec is a dead end. I
needed to hear that so I can look into alternatives.

Yes, what's really needed is an "upgrade" to the WSGI spec for asynchronous frameworks .. at least asyncio (now that asyncio is part of the standard library) ..

/Tobias

···

Am 02.04.2014 18:15, schrieb Michel Desmoulin:

On Wednesday, April 2, 2014 10:52:59 AM UTC+2, Michel Desmoulin wrote:

    Hello,

    Given the lack of async Python drivers for most databases in Python
    3, I want to write a component doing db queries and make RPC calls
    to it.

    I also want to code an configuration system which will signal all
    clients when a value has changed, using PUB/SUB.

    One of my client is a WSGI process, coded using Werkzeug and Python 3.

    Can I use it as a WAMP client ? If yes, how ? Cause I don't what to
    do with the WAMP client main loop.

    If no, is there an alternative ?

    E.G : does a stateless HTTP transport for WAMP exists, using
    callbacks URI ? If no, how can I code that (or at least find the
    informations to do so) ?

    My goal is to enventually have independant components that can run
    on their own for dev, then on deployment, to hook them on
    crossbar.io <http://crossbar.io>.

    Cheers

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com
<mailto:autobahnws+...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

0 Likes