Python based http server

Discussion in 'Python' started by Doug, Oct 12, 2003.

  1. Doug

    Doug Guest

    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
     
    Doug, Oct 12, 2003
    #1
    1. Advertising

  2. Doug wrote:

    > 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
     
    Alex Martelli, Oct 12, 2003
    #2
    1. Advertising

  3. Doug

    Doug Guest

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




    Alex Martelli wrote:

    > Doug wrote:
    >
    >
    >>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
    >
     
    Doug, Oct 12, 2003
    #3
  4. What's the advantage of writing your own HTTP server vs using Apache +
    mod_python?


    On Sun, 12 Oct 2003 16:59:23 GMT
    Doug <> wrote:

    > 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
    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list
     
    Matthew Wilson, Oct 12, 2003
    #4
  5. 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

    --
    Prisznyák Miklós
    ---
    Jegenye 2001 Bt. ( jegenye2001 at (NoSPAM)parkhosting dot com )
    Egyedi szoftverkészítés, tanácsadás
    Custom software development, consulting
    http://jegenye2001.parkhosting.com


    Doug <> wrote in message
    news:...
    > I thought the yield thing in Python 2.3 was a couritine implementation.
    > Is there a difference between generators and coroutines?
    >
    >
    >
    >
    > Alex Martelli wrote:
    >
    > > Doug wrote:
    > >
    > >
    > >>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
    > >

    >
     
    Jegenye 2001 Bt, Oct 12, 2003
    #5
  6. Doug

    Wilk Guest

    Matthew Wilson <> writes:

    > 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...

    --
    Wilk - http://flibuste.net
     
    Wilk, Oct 12, 2003
    #6
  7. Doug

    David Mertz Guest

    |> 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.

    Alex Martelli <> wrote previously:
    |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...

    --
    Keeping medicines from the bloodstreams of the sick; food from the bellies
    of the hungry; books from the hands of the uneducated; technology from the
    underdeveloped; and putting advocates of freedom in prisons. Intellectual
    property is to the 21st century what the slave trade was to the 16th.
     
    David Mertz, Oct 12, 2003
    #7
  8. Doug

    John J. Lee Guest

    Doug <> writes:

    > 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
     
    John J. Lee, Oct 12, 2003
    #8
  9. Doug

    Duncan Booth Guest

    Doug <> wrote in
    news::

    > 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.

    --
    Duncan Booth
    int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
    "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
     
    Duncan Booth, Oct 13, 2003
    #9
  10. Doug

    Peter Hansen Guest

    Doug wrote:
    >
    > 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
     
    Peter Hansen, Oct 14, 2003
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page