Hi Arnon,
Am 05.04.2015 um 14:04 schrieb Arnon Marcus:
> Hi, I was wondering how people are integrating/using AutobahnPython
> client, in their code.
> All the examples have all the calls within a context of the OnJoin
> method in a component-class.
> Is there a way to just have an object that exposes rpc in a
> synchronous/imperative style?
> I see that in other client-implementations of WAMP you can do stuff like:
> |
> result =session.call('someMethod',someArgs,someKeywordArgs)
Yes:
http://autobahn.ws/python/wamp/programming.html#calling-procedures
The "yield" thing is using co-routines, looks "synchronous", but
actually runs asynch under the hood.
There is no way to use AutobahnPython in blocking code based apps -
because it blocks the event loop. (there are ways of running the
blocking code on a different thread though).
> |
>
> Is this possible with AutobahnPython?
> If not, how then is it expected that people using it should embed rpc
> into an existing code-base?
If the code base is blocking, that's a problem. Blocking code means, the
event loop stops, and things will stop working.
>
> I guess one can do something like:
>
> session = ApplicationSession()
>
> def call(procedure, *args, **kwargs):
> yield session.call(procedure, args, kwargs)
>
> resault = call("com.mymethod").next()
See the yield thing above ..
>
> Would that even work?
> If so, is that advisable?
Using yield is perfectly fine. It will make your code look synchronous,
but it is still running asynch (and you still must not block).
>
> It is not clear from the documentation how Autobahn is expected to be
> used - it seems as thought there is an implicit-assumption that the
> reader understands that his/her entire code-base needs to exist inside
> the onJoin method of a component, or that there is where it should be
> initialized from - the moment the code gets to "runner.run(Component)"
> it starts waiting for asynchronous operations to occur within the
> context of the component - nowhere in the documentation is this being
> stated explicitly. Perhaps the documentation assumes a working-knowledge
> of using Twisted?! If so, then I think that at least THAT assumption
> should be stated explicitly somewhere..
"Autobahn|Python is a WebSocket / WAMP library for Python 2 and 3 on
Twisted and asyncio"
is on the homepage
http://autobahn.ws/
But yes, basic knowledge of either Twisted or asyncio is assumed.
Cheers,
/Tobias
PS: as this is Autobahn related (a specific WAMP implementation) the
post would better fit the Autobahn mailing list ..
>
> Any thoughts?
>
> --
> You received this message because you are subscribed to the Google
> Groups "WAMP" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
wampws+un...@googlegroups.com
> <mailto:
wampws+un...@googlegroups.com>.
> To post to this group, send email to
wam...@googlegroups.com
> <mailto:
wam...@googlegroups.com>.
> Visit this group at
http://groups.google.com/group/wampws.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/wampws/4585c86f-b79c-424d-853b-0d653d67d448%40googlegroups.com
> <
https://groups.google.com/d/msgid/wampws/4585c86f-b79c-424d-853b-0d653d67d448%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit
https://groups.google.com/d/optout.