On Tue, Apr 23, 2013 at 11:37 PM, Arnon Marcus <a.m.mar...@gmail.com> wrote:

> How is this architected?

I'm not sure I understand what you want to know but
I suppose you are referring to the chat example and how it works:

1. You open the chat with your browser and it sends the last messages, this is a
    "normal" request/response cycle, then...
2. An ajax request is made and if there are no new messages the server
    holds the request indefinitely and only gives back a response when
    there is a new message.
3. we've got the response, now go to 2 again.


> from what I understand, Tornado is a multithreaded event-loop, whith a 
> buil-in http-server, as a replacement for, say, apache.

No, tornado is not multithreaded, in fact it is not save share the
IOLoop between threads. see:
https://github.com/facebook/tornado/wiki/Threading-and-concurrency

Yes it has a builtin server, but you cannot compare with apache.
Apache is a general purpose server, tornado
is single thread and specific to call "tornado handlers", and with an
"adapter" call "WSGI handlers".


> Gevent is basically a similar idea, just with the event-loop implemented in 
> c, wrapped with a c-extension for python, and also has an http-server.

Short: Yes.

Long:

Very deep down, gevent and tornado use the same system, for example
epoll(Linux) / kqueue (BSD's).

gevent 0.x uses libevent, gevent 1.x they switch to libev, at least
last time I check.
libevent/libev are a layer to make easier  programming with async
events notifications,
with all the different mechanisms (epoll/kqueue/poll/select/...) -  (think DAL
to talk to different backends with an uniform API)

In tornado this layer is done in Python.

The really main difference between both is the way you program, with
gevent you can
do it in the "traditional/more natural" for the majority of
programmers (I am one of them :) ).
Gevent can achieve this by using coroutines through greenlets and
hiding them from you.
Even the event loop is hided from you.

With tornado you have to wrap your head around callbacks.
I think tornado recently introduced coroutines to simplify the
callback "mess", but
you have to explicit "yield" - Note: I'm not sure because I'm not
following tornado very close.

Other advantage I see with gevent is the clever monkey patching of
some python standard
libraries, making them and programs that uses them "green", this is
the reason that makes it
"WSGI friendly".

the best material about courotines for me is
http://www.dabeaz.com/coroutines/index.html,
if you are interested.

> Why do you need both?

Don't know, I never needed.

> How do they inter-operate?

Don't know, but maybe this can give you some ideas:
https://github.com/wil/gtornado


Ricardo

-- 

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


Reply via email to