I’d like to integrate crossbar io into some of my existing python applications.
All of them are quite different but none of then is a twisted / asyncio application.
simple use cases for some simple scripts that I’m most interested in.
- some scripts just want to publish events
- some scripts want to perform a few simple, blocking rpc calls, retrieve the result and continue their work
- some scripts just want to be triggered by a publish (one shot) wait till result is back. and continue
All these scripts are very small and it would be great to achieve this small and limited crossbar use cases without
websockets or twisted / asyncio event loops.
it would be preferable if everything could be achieved with simple libraries like requests / crossbarconnect.
1.) and 2.) seem to be simple to achieve, but I’m stuck with 3.)
3.) subscribe and wait for a publish:
My first idea is to add a long polling url to crossbar and to use requests to initiate a subscribe event. then it could use requests to poll for an incoming event.
Unfortunately the online doc seems incomplete of how to achieve this.
A second idea (though a little more complicated) would be to start one thread, which would
- create an autobahn.asyncio.wamp.ApplicatonSession()
- create an autobahn.asyncio.wamp.ApplicationRunner() , which would start the ApplicationSession
- this session would just perform one subscribe and register a callback.
- the callback would use something like threading.Event to unblock the intial thread
I will try this soon as this will probably work, but seems much heavier than simple code with long polling, if I manged to get it work
Does anybody have some simple example code for such a scenario?
1.) is already working with a publish url in crossbar and the crossbarconnect module.
2.) is what I’ll try next (with a caller url in crossbar and a JSON post request
3.) as mentioned. No idea what’s the simplest way to achieve this (subscribe, wait for publish, get result and continue)
Thanks in advance for any suggestions.