Python with Apache 2.0

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

    #1

    Python with Apache 2.0

    Does python support threads safely along with Apache 2.0 in web applications.

    Chang
  • Craig Ringer

    #2
    Re: Python with Apache 2.0

    On Fri, 2004-11-19 at 23:18, Andrew James wrote:[color=blue]
    > Chang,
    > I guess it depends whether you're using Python in a CGI or within
    > mod_python. Could you give us a little more information, or check the
    > mod_python documentation?[/color]

    If it turns out that mod_python can't handle it, perhaps FCGI / SCGI
    might be worth examining, too...

    --
    Craig Ringer

    Comment

    • Damjan

      #3
      Re: Python with Apache 2.0

      > Does python support threads safely along with Apache 2.0 in web[color=blue]
      > applications.[/color]

      Are you talking about mod_python?
      If so, then yes. But note that Apache threads entering the python
      interpreter (via mod_python) will be serialized on the GIL.


      --
      damjan

      Comment

      • Steve Holden

        #4
        Re: Python with Apache 2.0

        Damjan wrote:
        [color=blue][color=green]
        >>Does python support threads safely along with Apache 2.0 in web
        >>application s.[/color]
        >
        >
        > Are you talking about mod_python?
        > If so, then yes. But note that Apache threads entering the python
        > interpreter (via mod_python) will be serialized on the GIL.
        >
        >[/color]
        This is true, but it doesn't tell the whoel story: mod_python has taken
        care to make it possible to configure multiple interpreters - on a
        per-directory basis if necessary. Obviously they all share the pure
        code, but if I undestand correctly each has its own data space, and
        hence its own GIL.

        regards
        Steve
        --


        Holden Web LLC +1 800 494 3119

        Comment

        • Chang LI

          #5
          Re: Python with Apache 2.0

          Damjan <gdamjan@gmail. com> wrote in message news:<306sikF2s ueanU1@uni-berlin.de>...[color=blue][color=green]
          > > Does python support threads safely along with Apache 2.0 in web
          > > applications.[/color]
          >
          > Are you talking about mod_python?
          > If so, then yes. But note that Apache threads entering the python
          > interpreter (via mod_python) will be serialized on the GIL.[/color]

          Yes, use mod_python. I plan to use Python to replace PHP and other
          languages. The low efficient CGI will be replaced by embedded Python
          program. Apache 2.0 is faviority becuase the threads are must have
          features.

          Comment

          • Graham Dumpleton

            #6
            Re: Python with Apache 2.0

            changli_to@hotm ail.com (Chang LI) wrote in message news:<89cc6e1f. 0411190632.2976 b3e1@posting.go ogle.com>...[color=blue]
            > Does python support threads safely along with Apache 2.0 in web applications.[/color]

            Yes, but the latest version of mod_python (3.1.3) has a couple of bugs
            in it in relation to threads which can cause problems when using a
            threaded MPM with Apache. No indication has been given as to when
            they will be fixed so you should patch the bugs yourself for now.

            You can find some details and the patches at:



            There is a discussion on the mod_python mailing list archives at:



            Look for the thread starting with "Udate python modules without restarting Apache".
            It is this discussion which lead to the uncovering of the bugs.

            Comment

            • Tim Roberts

              #7
              Re: Python with Apache 2.0

              changli_to@hotm ail.com (Chang LI) wrote:
              [color=blue]
              >Damjan <gdamjan@gmail. com> wrote in message news:<306sikF2s ueanU1@uni-berlin.de>...[color=green][color=darkred]
              >> > Does python support threads safely along with Apache 2.0 in web
              >> > applications.[/color]
              >>
              >> Are you talking about mod_python?
              >> If so, then yes. But note that Apache threads entering the python
              >> interpreter (via mod_python) will be serialized on the GIL.[/color]
              >
              >Yes, use mod_python. I plan to use Python to replace PHP and other
              >languages. The low efficient CGI will be replaced by embedded Python
              >program. Apache 2.0 is faviority becuase the threads are must have
              >features.[/color]

              I would like to point out yet again that CGI isn't as bad as many people
              make it out to be. Unless you know you need to handle thousands of
              requests per minute, the overhead of creating a process and firing up the
              interpreter is not significant.

              CGI is certainly an easier debug environment than mod_python or any of the
              long-running-process solutions.
              --
              - Tim Roberts, timr@probo.com
              Providenza & Boekelheide, Inc.

              Comment

              • Graham Dumpleton

                #8
                Re: Python with Apache 2.0

                Steve Holden <steve@holdenwe b.com> wrote in message news:<S_xnd.130 0$QR.188@lakere ad01>...[color=blue]
                > Damjan wrote:
                >[color=green][color=darkred]
                > >>Does python support threads safely along with Apache 2.0 in web
                > >>application s.[/color]
                > >
                > >
                > > Are you talking about mod_python?
                > > If so, then yes. But note that Apache threads entering the python
                > > interpreter (via mod_python) will be serialized on the GIL.
                > >
                > >[/color]
                > This is true, but it doesn't tell the whoel story: mod_python has taken
                > care to make it possible to configure multiple interpreters - on a
                > per-directory basis if necessary. Obviously they all share the pure
                > code, but if I undestand correctly each has its own data space, and
                > hence its own GIL.[/color]

                There is actually a possible bug in PythonInterpPer Directory directive
                which applies even if threading isn't being used. Specifically, mod_python
                doesn't calculate the interpreter name correctly and although access to a
                directory by name and something in it should logically resolve to the
                same interpreter name it doesn't. More information can be found at:



                Overall, I am not sure that PythonInterpPer Directory is a good idea, but
                then it probably was created to workaround the short comings of the
                module importing system in mod_python which makes it impossible in
                mod_python.publ isher to have an index.py file in separate directories
                within the context of the one interpreter. It wouldn't take much effort to
                fix this limitation in the module importing system, but there doesn't seem
                to be much interest in doing so.

                Comment

                • Steve Holden

                  #9
                  Re: Python with Apache 2.0

                  Graham Dumpleton wrote:[color=blue]
                  > Steve Holden <steve@holdenwe b.com> wrote in message news:<S_xnd.130 0$QR.188@lakere ad01>...
                  >[color=green]
                  >>Damjan wrote:
                  >>
                  >>[color=darkred]
                  >>>>Does python support threads safely along with Apache 2.0 in web
                  >>>>application s.
                  >>>
                  >>>
                  >>>Are you talking about mod_python?
                  >>>If so, then yes. But note that Apache threads entering the python
                  >>>interprete r (via mod_python) will be serialized on the GIL.
                  >>>
                  >>>[/color]
                  >>
                  >>This is true, but it doesn't tell the whoel story: mod_python has taken
                  >>care to make it possible to configure multiple interpreters - on a
                  >>per-directory basis if necessary. Obviously they all share the pure
                  >>code, but if I undestand correctly each has its own data space, and
                  >>hence its own GIL.[/color]
                  >
                  >
                  > There is actually a possible bug in PythonInterpPer Directory directive
                  > which applies even if threading isn't being used. Specifically, mod_python
                  > doesn't calculate the interpreter name correctly and although access to a
                  > directory by name and something in it should logically resolve to the
                  > same interpreter name it doesn't. More information can be found at:
                  >
                  > http://www.modpython.org/pipermail/m...er/016788.html
                  >
                  > Overall, I am not sure that PythonInterpPer Directory is a good idea, but
                  > then it probably was created to workaround the short comings of the
                  > module importing system in mod_python which makes it impossible in
                  > mod_python.publ isher to have an index.py file in separate directories
                  > within the context of the one interpreter. It wouldn't take much effort to
                  > fix this limitation in the module importing system, but there doesn't seem
                  > to be much interest in doing so.[/color]

                  Thank a lot for the additional information. I agree that the namespace
                  confusion is less than ideal in mod_python.

                  regards
                  STeve
                  --


                  Holden Web LLC +1 800 494 3119

                  Comment

                  Working...