Re: Problem with MySQLdb and mod_python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lawrence D'Oliveiro

    Re: Problem with MySQLdb and mod_python

    In message <mailman.109.12 16158151.922.py thon-list@python.org >, Cyril Bazin
    wrote:
    But it seems, after many tests, that the script stops at the
    instruction : "c.execute(requ ete)"
    What's the error message? This should be in Apache's error_log file.
  • Cyril Bazin

    #2
    Re: Problem with MySQLdb and mod_python

    Thanks for your reply

    The apache log contains lines like :

    [Tue Jul 15 23:31:01 2008] [notice] mod_python (pid=11836,
    interpreter='ww w.toto.fr'): Importing module
    '/usr/local/apache2/htdocs/intranet/courrier/test.py'
    [Tue Jul 15 23:31:02 2008] [notice] child pid 11836 exit signal
    Segmentation fault (11)
    [Tue Jul 15 23:31:19 2008] [notice] mod_python (pid=11764,
    interpreter='ww w.toto.fr'): Importing module
    '/usr/local/apache2/htdocs/intranet/courrier/test.py'
    [Tue Jul 15 23:31:19 2008] [notice] child pid 11764 exit signal
    Segmentation fault (11)

    I think the problem comes from the MySQLdb module.
    If I can't find another solution, I think I will downgrade the MySQLdb
    version to 1.2.1

    Cyril

    On Thu, Jul 17, 2008 at 7:27 AM, Lawrence D'Oliveiro
    <ldo@geek-central.gen.new _zealandwrote:
    In message <mailman.109.12 16158151.922.py thon-list@python.org >, Cyril Bazin
    wrote:
    >
    >But it seems, after many tests, that the script stops at the
    >instruction : "c.execute(requ ete)"
    >
    What's the error message? This should be in Apache's error_log file.
    --

    >

    Comment

    • John Nagle

      #3
      Re: Problem with MySQLdb and mod_python

      Cyril Bazin wrote:
      Thanks for your reply
      >
      The apache log contains lines like :
      >
      [Tue Jul 15 23:31:01 2008] [notice] mod_python (pid=11836,
      interpreter='ww w.toto.fr'): Importing module
      '/usr/local/apache2/htdocs/intranet/courrier/test.py'
      [Tue Jul 15 23:31:02 2008] [notice] child pid 11836 exit signal
      Segmentation fault (11)
      [Tue Jul 15 23:31:19 2008] [notice] mod_python (pid=11764,
      interpreter='ww w.toto.fr'): Importing module
      '/usr/local/apache2/htdocs/intranet/courrier/test.py'
      [Tue Jul 15 23:31:19 2008] [notice] child pid 11764 exit signal
      Segmentation fault (11)
      >
      I think the problem comes from the MySQLdb module.
      If I can't find another solution, I think I will downgrade the MySQLdb
      version to 1.2.1
      Sounds like version hell. mod_python and MySQLdb have to be
      compiled with exactly the same compiler for this to work.

      mod_python is usually troublesome. Python doesn't really have
      quite enough isolation to run multiple unrelated instances reliably.
      We use FCGI, which has the isolation of CGI but doesn't reload the
      application for every transaction. Also, it's easier to debug if
      CPython is crashing.

      John Nagle

      Comment

      • Graham Dumpleton

        #4
        Re: Problem with MySQLdb and mod_python

        On Jul 18, 3:28 pm, John Nagle <na...@animats. comwrote:
        Cyril Bazin wrote:
        Thanks for your reply
        >
        The apache log contains lines like :
        >
        [Tue Jul 15 23:31:01 2008] [notice]mod_python(pid= 11836,
        interpreter='ww w.toto.fr'):Imp orting module
        '/usr/local/apache2/htdocs/intranet/courrier/test.py'
        [Tue Jul 15 23:31:02 2008] [notice] child pid 11836 exit signal
        Segmentation fault (11)
        [Tue Jul 15 23:31:19 2008] [notice]mod_python(pid= 11764,
        interpreter='ww w.toto.fr'):Imp orting module
        '/usr/local/apache2/htdocs/intranet/courrier/test.py'
        [Tue Jul 15 23:31:19 2008] [notice] child pid 11764 exit signal
        Segmentation fault (11)
        >
        I think the problem comes from the MySQLdb module.
        If I can't find another solution, I think I will downgrade the MySQLdb
        version to 1.2.1
        >
            Sounds like version hell.  mod_python and MySQLdb have to be
        compiled with exactly the same compiler for this to work.
        Use of compatible compilers applies to anything you want to use
        together. This is nothing specific to mod_python, so this comment is a
        bit misleading. These days with with GNU C everywhere, it is hardly
        and issue, and was usually only an issue with C++ code and not C code
        anyway.
           mod_python is usually troublesome.   Python doesn't really have
        quite enough isolation to run multiple unrelated instances reliably.
        The isolation issue is nothing to do with Python itself. Isolation is
        an issue in this case, but most likely comes about because the OP is
        trying to use both PHP and mod_python together in the same Apache
        instance.

        In particular, the PHP package is likely loading a MySQL module and it
        is linked against a different version of the MySQL client libraries
        than what the Python MySQL package is wanting.

        People like to blame mod_python for these problems, but it can equally
        be attributed to PHP. In practice the reason it shows up as a
        mod_python issue is that PHP tries to preload a lot of stuff and so
        manages to load its version of shared libraries first. Python with its
        lazy loading comes in second, and so conflicts will occur. If
        mod_python preloaded stuff like PHP did and this was occurring before
        PHP got a chance, it would be the other way around and mod_python
        would work fine and PHP would instead be what crashes all the time.
        We use FCGI, which has the isolation of CGI but doesn't reload the
        application for every transaction.  Also, it's easier to debug if
        CPython is crashing.
        With the reason that FCGI works being that the processes, even if they
        are spawned by Apache, use a fork/exec, thus meaning they have a clean
        memory space when starting up.

        In summary, look at what version of MySQL libraries are used by PHP
        modules and ensure that Python MySQL module is compiled against the
        same version.

        Graham

        Comment

        Working...