Python based http server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doug

    Python based http server

    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

  • Alex Martelli

    #2
    Re: Python based http server

    Doug wrote:
    [color=blue]
    > 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.[/color]

    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

    Comment

    • Doug

      #3
      Re: Python based http server

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




      Alex Martelli wrote:
      [color=blue]
      > Doug wrote:
      >
      >[color=green]
      >>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.[/color]
      >
      >
      > 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
      >[/color]

      Comment

      • Matthew Wilson

        #4
        Re: Python based http server

        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 <zr7m08j02@snea kemail.com> wrote:
        [color=blue]
        > 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[/color]

        Comment

        • Jegenye 2001 Bt

          #5
          Re: Python based http server

          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)parkhos ting dot com )
          Egyedi szoftverkészíté s, tanácsadás
          Custom software development, consulting



          Doug <zr7m08j02@snea kemail.com> wrote in message
          news:3F8993AD.4 080404@sneakema il.com...[color=blue]
          > I thought the yield thing in Python 2.3 was a couritine implementation.
          > Is there a difference between generators and coroutines?
          >
          >
          >
          >
          > Alex Martelli wrote:
          >[color=green]
          > > Doug wrote:
          > >
          > >[color=darkred]
          > >>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.[/color]
          > >
          > >
          > > 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
          > >[/color]
          >[/color]


          Comment

          • Wilk

            #6
            Re: Python based http server

            Matthew Wilson <mwilson@sarcas tic-horse.com> writes:
            [color=blue]
            > What's the advantage of writing your own HTTP server vs using Apache +
            > mod_python?[/color]

            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

            Comment

            • John J. Lee

              #7
              Re: Python based http server

              Doug <zr7m08j02@snea kemail.com> writes:
              [color=blue]
              > I thought the yield thing in Python 2.3 was a couritine
              > implementation. Is there a difference between generators and
              > coroutines?[/color]

              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

              Comment

              • David Mertz

                #8
                Re: Python based http server

                |> 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 <aleaxit@yahoo. com> 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:



                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.

                Comment

                • Duncan Booth

                  #9
                  Re: Python based http server

                  Doug <zr7m08j02@snea kemail.com> wrote in
                  news:3F8993AD.4 080404@sneakema il.com:
                  [color=blue]
                  > I thought the yield thing in Python 2.3 was a couritine implementation.
                  > Is there a difference between generators and coroutines?[/color]

                  (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 duncan@rcp.co.u k
                  int month(char *p){return(1248 64/((p[0]+p[1]-p[2]&0x1f)+1)%12 )["\5\x8\3"
                  "\6\7\xb\1\x9\x a\2\0\4"];} // Who said my code was obscure?

                  Comment

                  • Peter Hansen

                    #10
                    Re: Python based http server

                    Doug wrote:[color=blue]
                    >
                    > 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.[/color]

                    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

                    Comment

                    Working...