Re: [web2py] Re: Async http request in web2py

2011-02-18 Thread Vasile Ermicioi
>
>  Sort of
> peculiar how a browser on the client's computer is more capable in
> this area than a powerful web server.


If you need async calls you can take a look at gevent, eventlet or twisted

But put in your mind the main difference:
the browser is running continuously (until you close it), and this way ajax
can work in background,
but the request is ended at the moment you receive the response,
before returning the response you will need to wait for all async calls to
be completed ( if you want them completed)

a good example of what I am talking is the new Datastore plus developed by
Guido van Rossum for GAE http://code.google.com/p/appengine-ndb-experiment/


[web2py] Re: Async http request in web2py

2011-02-18 Thread Dane
Thanks for the explanation Massimo. I figured it must be an issue with
python's architecture or something would have been added to the std
lib by now.

It's easy enough to simulate this behavior with ajax calls to
controllers from the client. Unfortunately since you can't rely on
javascript being enabled, it can't be used in every situation. Sort of
peculiar how a browser on the client's computer is more capable in
this area than a powerful web server.

It would be neat if someone set up a publish/subscribe api that could
act as an async proxy for synchronous servers. You would make a
request that included a target url and a callback url. Maybe something
like this already exists?


On Feb 18, 11:31 pm, Massimo Di Pierro 
wrote:
> It is more complex than this. It is about two different models to
> handle concurrency.
>
> In one model you have one thread per request. Each request does IO
> with the client within one thread. The web server creates and manages
> the threads connects the thread to the web app (for example web2py)
> via mod_wsgi.
>
> In another model you do not have threads. You have async IO. It allows
> to serve more clients at the same time if the requests are really
> simple. If the computation is significative you may have concurrency
> issues.
>
> Then you can heve async io with ligthweight thread within is the best
> of both worlds.
>
> Python does not have built-in lightweight threads. web2py is based on
> mod_wsgi which does not support async.
>
> Anyway, this is not a definitive word on the subject.
>
> Massimo
>
> On Feb 18, 9:15 pm, Dane  wrote:
>
>
>
>
>
>
>
> > Synchronous http makes the call and stops further execution until the
> > result is returned.
>
> > Async makes the call and optionally provides a callback so that
> > further code can be executed while waiting for the response. The way
> > ajax calls with in javascript, for example.
>
> > Seems like basic functionality--strange that something so useful isn't
> > built in to python in a straightforward way. It would be great if
> > web2py could do something to address this. There are many use cases
> > and it's much easier and lighter weight than dealing with threads,
> > processes, cron, etc. when all that is needed is a quick non-blocking
> > call.
>
> > On Feb 18, 8:52 am, KMax  wrote:
>
> > > asynchronous http and synchronous http
> > > What the difference ?
> > > On 18 фев, 10:37, Dane  wrote:
>
> > > > Hi,
>
> > > > I need to make an asynchronous http request to one of my controller
> > > > functions in order to some lightweight background processing
> > > > (refreshing some cached objects). I came upon this thread:
>
> > > >http://groups.google.com/group/web2py/browse_thread/thread/bbe66f1084...
>
> > > > But the link to the "lola" function posted post by Massimo is broken.
> > > > Can anyone supply a new link or explain a simple way to make async,
> > > > ajax-like requests from within web2py? Thanks.
>
> > > > -Dane


[web2py] Re: Async http request in web2py

2011-02-18 Thread Massimo Di Pierro
It is more complex than this. It is about two different models to
handle concurrency.

In one model you have one thread per request. Each request does IO
with the client within one thread. The web server creates and manages
the threads connects the thread to the web app (for example web2py)
via mod_wsgi.

In another model you do not have threads. You have async IO. It allows
to serve more clients at the same time if the requests are really
simple. If the computation is significative you may have concurrency
issues.

Then you can heve async io with ligthweight thread within is the best
of both worlds.

Python does not have built-in lightweight threads. web2py is based on
mod_wsgi which does not support async.

Anyway, this is not a definitive word on the subject.

Massimo





On Feb 18, 9:15 pm, Dane  wrote:
> Synchronous http makes the call and stops further execution until the
> result is returned.
>
> Async makes the call and optionally provides a callback so that
> further code can be executed while waiting for the response. The way
> ajax calls with in javascript, for example.
>
> Seems like basic functionality--strange that something so useful isn't
> built in to python in a straightforward way. It would be great if
> web2py could do something to address this. There are many use cases
> and it's much easier and lighter weight than dealing with threads,
> processes, cron, etc. when all that is needed is a quick non-blocking
> call.
>
> On Feb 18, 8:52 am, KMax  wrote:
>
>
>
>
>
>
>
> > asynchronous http and synchronous http
> > What the difference ?
> > On 18 фев, 10:37, Dane  wrote:
>
> > > Hi,
>
> > > I need to make an asynchronous http request to one of my controller
> > > functions in order to some lightweight background processing
> > > (refreshing some cached objects). I came upon this thread:
>
> > >http://groups.google.com/group/web2py/browse_thread/thread/bbe66f1084...
>
> > > But the link to the "lola" function posted post by Massimo is broken.
> > > Can anyone supply a new link or explain a simple way to make async,
> > > ajax-like requests from within web2py? Thanks.
>
> > > -Dane


[web2py] Re: Async http request in web2py

2011-02-18 Thread Dane
Synchronous http makes the call and stops further execution until the
result is returned.

Async makes the call and optionally provides a callback so that
further code can be executed while waiting for the response. The way
ajax calls with in javascript, for example.

Seems like basic functionality--strange that something so useful isn't
built in to python in a straightforward way. It would be great if
web2py could do something to address this. There are many use cases
and it's much easier and lighter weight than dealing with threads,
processes, cron, etc. when all that is needed is a quick non-blocking
call.

On Feb 18, 8:52 am, KMax  wrote:
> asynchronous http and synchronous http
> What the difference ?
> On 18 фев, 10:37, Dane  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I need to make an asynchronous http request to one of my controller
> > functions in order to some lightweight background processing
> > (refreshing some cached objects). I came upon this thread:
>
> >http://groups.google.com/group/web2py/browse_thread/thread/bbe66f1084...
>
> > But the link to the "lola" function posted post by Massimo is broken.
> > Can anyone supply a new link or explain a simple way to make async,
> > ajax-like requests from within web2py? Thanks.
>
> > -Dane


[web2py] Re: Async http request in web2py

2011-02-18 Thread KMax
asynchronous http and synchronous http
What the difference ?
On 18 фев, 10:37, Dane  wrote:
> Hi,
>
> I need to make an asynchronous http request to one of my controller
> functions in order to some lightweight background processing
> (refreshing some cached objects). I came upon this thread:
>
> http://groups.google.com/group/web2py/browse_thread/thread/bbe66f1084...
>
> But the link to the "lola" function posted post by Massimo is broken.
> Can anyone supply a new link or explain a simple way to make async,
> ajax-like requests from within web2py? Thanks.
>
> -Dane