On Wed, 2012-04-04 at 11:51 +0100, João Ventura wrote:
> Hello everyone,
> 
> I've searched for this subject and found some (rather old) emails, so I 
> haven't reached any conclusion about the possibility/interest of doing 
> synchronous json-rpc calls in Pyjs, ie, didn't understand if it is 
> possible or not. But i'll try to explain my case..
> 
> I'm converting a desktop application to pyjs, and it has an API. It is 
> an MVC app. Regarding the API, the logical decision was that everything 
> pure-python would go the the client, and C-extensions and modules which 
> needs to access information from files will go to the server. So, using 
> "jsonrpclib" I've abstracted my API enough that i just set a flag to 
> change some requests from local to jsonrpc. It is transparent to my app 
> from where the data comes from.. It is pretty cool! :)
> 
> However, my problem is that only now I've found out that pyjamas doesn't 
> seem to handle synchronous jsonrpc calls. Or at least, the JsonRPC 
> example is based on async handling of jsonrpc calls. I've tried to 
> import jsonrpclib to pyjs but something needs to be fixed (or in pyjs or 
> in jsonrpclib, I still don't know).
> 
> So, as I would like to maintain the synchronous aspect of my API in the 
> client (because it is already done that way, and I may use it in other 
> situations), I would ask if anyone knows something about this, i.e., 
> about doing synchronous jsonrpc calls in pyjamas?
> 
> Basically, is synchronous jsonrpc available in pyjs (or in browsers)? 
> What are the downsides of it (does delays in response hang the browser 
> entirelly or just my app tab)?
> 
> 
> Thanks,
> João Ventura

Synchronous http calls (or json over http) are simply not possible in
javascript (i.e. in browsers). It helps me to consider Pyjamas apps to
be completely event driven.

What I do if I want the same code in CPython and Pyjamas, I write all
the code with callbacks. Which works for CPython and is a must for
Pyjamas.

Maybe it would be possible to do something similar as twisted (using
decorator tricks to code synchronously, but execute asynchronously), but
that depends heavily on yield statements and these aren't cheap in
Pyjamas...


- Kees



Reply via email to