Python based http server

D

Doug

I am thinking of using a Python based HTTP server instead of Apache.

I would be interested in one that employed generators and coroutines. I
know those are fairly new features of python, so maybe nothing is
available yet.

Doug
 
A

Alex Martelli

Doug said:
I am thinking of using a Python based HTTP server instead of Apache.

I would be interested in one that employed generators and coroutines. I
know those are fairly new features of python, so maybe nothing is
available yet.

coroutines are not a part of Python. Twisted, the best way to write
standalone Python HTTP servers, can use generators productively,
see e.g. http://twistedmatrix.com/documents/howto/flow (but it will
make little sense to you until you understand more about Twisted).


Alex
 
D

Doug

I thought the yield thing in Python 2.3 was a couritine implementation.
Is there a difference between generators and coroutines?
 
M

Matthew Wilson

What's the advantage of writing your own HTTP server vs using Apache +
mod_python?
 
J

Jegenye 2001 Bt

Yes, coroutines are more general than generators.
The code execution is always resumed from the point of calling with
generators, while with coroutines that's not the case.

Regards,
Miklós
 
W

Wilk

Matthew Wilson said:
What's the advantage of writing your own HTTP server vs using Apache +
mod_python?

Why take a ham to scratch a poor fly ?

You even can make a complete server in a windows exe ! hu ! incredible
isn'it ?

And the server will be faster...
 
D

David Mertz

|> I would be interested in one that employed generators and coroutines. I
|> know those are fairly new features of python, so maybe nothing is
|> available yet.

|coroutines are not a part of Python. Twisted, the best way to write
|standalone Python HTTP servers, can use generators productively,

Twisted certainly has some virtures. But semi-coroutines, at least, are
part of Python--and therefore it's easy to build full coroutines. See:

http://gnosis.cx/publish/programming/charming_python_b5.html

It's certainly quite possible to use those for a somewhat different
switching framework than Twisted gives you.

Yours, David...
 
J

John J. Lee

Doug said:
I thought the yield thing in Python 2.3 was a couritine
implementation. Is there a difference between generators and
coroutines?

Yes. Never used coroutines, so not going to explain that, but
coroutines were (and are, I guess, but not certain) part.of Stackless
Python. Stackless is a separate Python implementation, forked from
CPython. It's currently going through big changes.


John
 
D

Duncan Booth

I thought the yield thing in Python 2.3 was a couritine implementation.
Is there a difference between generators and coroutines?

(please don't top quote)

Coroutines have a completely separate stack which is saved when they yield,
so you have a load of nested function calls and yield from deep in the
middle of them.

Generators save only a single stack frame, so all yields must come directly
from the generator, not from functions which it calls.

You can use generators to get a similar effect to coroutines by nesting
generators and propogating the yields back up the chain, but this has to be
done explicitly at every level.
 
P

Peter Hansen

Doug said:
I am thinking of using a Python based HTTP server instead of Apache.

I would be interested in one that employed generators and coroutines. I
know those are fairly new features of python, so maybe nothing is
available yet.

Given your expressed requirements: avoiding Apache and using generators,
it sounds a lot like you are doing this merely as a learning experience
or something. After all, who ever heard of "uses generators" as a
practical requirement for a web server?

If you have real requirements, let us know. Otherwise the only
good "advice" you will hear is "what's wrong with Apache"?

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top