I think your time would be much better spent just learning to use
asynchronous programming.

If you insist on thinking synchronously then I'd suggest you look at Meteor
and their reactive programming model. That would be a more flexible
approach to bring to Pyjs than your blocking method.

 - lex


On Sat, Nov 30, 2013 at 7:34 PM, Clavier <bachcalv...@gmail.com> wrote:

> Hi,
>
> I found that Pyjs supported only async remote call (ex:
> HTTPRequest.AsyncPost(), but not HTTPRequest.Post()).  It makes source code
> complicated when a series of remote calls are using preceding results.
>  Many applications use a function call returning a value, but an async call
> forces to separate the function and the return value making code
> complicated. This is an example using xmlrpclib in Python:
>
>     import xmlrpclib
>     s = xmlrpclib.ServerProxy('http://localhost:8000')
>     v1=s.pow(2,3)  # pow() is a remote function
>     v2=s.add(v1,3) # add() is a remote function
>     v3=s.div(v2,2) # div() is a remote function
>
> Corresponding code for Pyjs is a lot more complicated (sudo code):
>
>     s = JSONProxy('http://localhost:8000')
>     class ServiceHandler:
>         def onRemoteResponse(self, response, sender):
>             if sender=='pow':
>                 self.return_of_pow=response
>                 s.add(self.return_of_pow, 3, self)
>             if sender=='add':
>                 self.return_of_add=response
>                 s.div(self.return_of_add, 2, self)
>             if sender=='div':
>                 self.return_of_div=response
>     handler=ServiceHandler()
>     s.pow(2,3, handler)
>
> The return values from the server are not directly passed, but
> asynchronously passed to the event handler.  It is nature of asynchronous
> programming making code complicated. It is possible to make code simpler
> using 'yield' command and generators, and this is how I am writing code in
> Pyjs now. But this asynchronous programming style has a problem making
> debugging more difficult because stack contents cannot be shown properly.
>
> So, I want to use synchronous calls like xmlrpclib of Python.  It can
> cause GUI interface to get stuck sometimes, but it is ok in most of
> applications. In order to implement it in Pyjs, inserting a code waiting
> server response is enough, but the control should go to the Pyjs main loop
> because Pyjs cannot updates server response while user code is running.
>  So, I needed a function to force Pyjs to update server response.
>
>       HTTPRequest.asyncPost('http://localhost:8000', handler)
>       while handler.did_server_responded!=True:        #waiting server
> response
>           force_Pyjs_to_update_events()
>
> Is there such a function in Pyjs? If not, I'd like to try to make one.
> Please let me know if you have an idea.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Pyjs.org Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pyjs-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Pyjs.org Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyjs-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to