[mod_python] Duplicated statements using the publisher handler

Graham Dumpleton graham.dumpleton at gmail.com
Mon Jun 23 19:39:18 EDT 2008


Log the value of req.connection.id in the request to try and doubly
confirm if it is being done in context of one client connection.

Do you have any fancy rewrite rules in your Apache configuration?

Do you have directory browsing enabled in Apache so you can get
directory listings?

Are you using any Apache authentication scheme?

Graham

2008/6/23 Luke Benstead <luke at riverhall.co.uk>:
> Hi all,
>
> I have been getting some weird behaviour from a python script that I
> wrote that uses the publisher handler. I'm not sure what is going wrong
> to be honest, hopefully someone can point me in the right direction...
>
> My script simply receives POST requests from an automated program on
> another server. On receiving the requests the data is validated and then
> inserted into a database. The code is quite simple. The problem is that
> every time a POST is received, each Python statement seems to be run an
> increasing number of times. For example, if I restart Apache, and send a
> POST I get the following logged from the script:
>
>
> 2008-06-23 11:29:22,352 scriptname DEBUG    PID:6544 Thread:2964 Request
> received: AdvertiserID = [Field('AdvertiserID', 'C46'),
> Field('AdvertiserID', 'C1386')]
>
>
> which is correct. If I resend the POST (e.g. press refresh in the
> browser, I get the following added to the log
>
> 2008-06-23 11:29:22,352 scriptname DEBUG    PID:6544 Thread:2964
> Request received: AdvertiserID = [Field('AdvertiserID', 'C46'),
> Field('AdvertiserID', 'C1386')]
> 2008-06-23 11:29:22,352 scriptname DEBUG    PID:6544 Thread:2964
> Request received: AdvertiserID = [Field('AdvertiserID', 'C46'),
> Field('AdvertiserID', 'C1386')]
>
> If I refresh again I get 3 entries, continually increasing. This happens
> to every statement in the program. Originally I thought it might just be
> the log, but I'm getting primary key database errors where insert
> statements are being repeated.
>
> The log writes the process ID and the a thread ID for each request. So I
> know it is the SAME request which seems to call each method repeatedly
> in order. Here's another example from the log:
>
> 2008-06-23 11:29:34,009 scriptname DEBUG    PID:6544 Thread:736 List
> after cleaning: [Field('AdvertiserID', 'C1386'), Field('AdvertiserID',
> 'C46')]
> 2008-06-23 11:29:34,009 scriptname DEBUG    PID:6544 Thread:736 List
> after cleaning: [Field('AdvertiserID', 'C1386'), Field('AdvertiserID',
> 'C46')]
> 2008-06-23 11:29:34,009 scriptname DEBUG    PID:6544 Thread:736 Data is
> valid
> 2008-06-23 11:29:34,009 scriptname DEBUG    PID:6544 Thread:736 Data is
> valid
>
> So it's not as if the script is being run twice one after the other,
> it's actually like each statement is called twice.
>
> This is running Apache 2.2 + mod_python 3.3.1 under Windows 2000.
>
> The Apache config uses a rewrite rule to get to the following location
> directive:
>
>        <Location "/scriptname/">
>                SetHandler mod_python
>                PythonHandler mod_python.publisher
>                PythonDebug On
>        </Location>
>
> I'd appreciate any help with this, thanks in advance.
>
> Luke.
>
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>



More information about the Mod_python mailing list