[mod_python] RE: Mod_python Digest, Vol 48, Issue 23

Posey, Jake E Jake.E.Posey at boeing.com
Tue Mar 20 11:53:37 EST 2007


I have the same problem with compiling mod_python on 64bit Red Hat with apache 2.2.4 and even after recompiling python 2.5 with --enable-shared everything configures, compiles, and install without any errors but when I run python -V I get the following error:

[root at lcas204 ~]# /usr/local/bin/python -V
/usr/local/bin/python: error while loading shared libraries: libpython2.5.so.1.0: cannot open shared object file: No such file or directory
[root at lcas204 ~]#

However the file does exist and it is in my path.

[root at lcas204 lib]# pwd
/usr/local/lib
[root at lcas204 lib]# ls -ld *python*
lrwxrwxrwx   1 root root      19 Mar 20 09:02 libpython2.5.so -> libpython2.5.so.1.0
-r-xr-xr-x   1 root root 5001973 Mar 20 09:02 libpython2.5.so.1.0
lrwxrwxrwx   1 root root      19 Mar 20 09:14 libpython.so -> libpython2.5.so.1.0
drwxr-xr-x  21 root root   20480 Mar 20 09:02 python2.5
[root at lcas204 lib]#

[root at lcas204 ~]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/usr/local:/usr/local/lib:/usr/local/lib/python2.5
[root at lcas204 ~]#

But if I just run ./configure with no options it configure, compiles, and installs with no errors and I'm able to run python -V to check the version and make sure it is working but when I go to compile mod_python I'm back to the original problem.

Any other ideas?

Thanks in advance,

Jake

-----Original Message-----
From: mod_python-request at modpython.org [mailto:mod_python-request at modpython.org] 
Sent: Tuesday, March 20, 2007 7:31 AM
To: mod_python at modpython.org
Subject: Mod_python Digest, Vol 48, Issue 23

Send Mod_python mailing list submissions to
	mod_python at modpython.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://mailman.modpython.org/mailman/listinfo/mod_python
or, via email, send a message with subject or body 'help' to
	mod_python-request at modpython.org

You can reach the person managing the list at
	mod_python-owner at modpython.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Mod_python digest..."


Today's Topics:

   1. Object cleanup with child process scaling (Nicholas Milkovits)
   2. Re: Object cleanup with child process scaling (Graham Dumpleton)
   3. Compiling mod_python (Gabriele Farina)
   4. Re: Compiling mod_python (Roberto C. S?nchez)
   5. Re: Compiling mod_python (Graham Dumpleton)
   6. Detecting Back Button Usage (Kenneth Loafman)
   7. Re: Detecting Back Button Usage (Clodoaldo)
   8. Re: Detecting Back Button Usage (Jorey Bump)
   9. Re: Detecting Back Button Usage (Jorey Bump)


----------------------------------------------------------------------

Message: 1
Date: Mon, 19 Mar 2007 13:24:33 -0400
From: "Nicholas Milkovits" <nmilkovits at gmail.com>
Subject: [mod_python] Object cleanup with child process scaling
To: mod_python at modpython.org
Message-ID:
	<71a75690703191024o7faa4fe8yfb0b77c04f0dba07 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hello all,

I have a quick question about how apache2 and mod python work. When
apache (running in prefork mode) decides to scale back the number of
running child processes running because of a low request volume, does
mod python ensure that all objects have their __del__ methods called
or does apache just kill it and release the memory back to the system?
I am running across a problem where my oracle db has to many sessions
open (although they are marked as idle/invalid) and it appears to be
because the client application is never explicity telling oracle to
close the sessions before exiting. Is there any way to ensure a chunk
of code gets run before apache kills the process?

Thanks,
Nick M.


------------------------------

Message: 2
Date: Tue, 20 Mar 2007 07:57:02 +1100
From: "Graham Dumpleton" <graham.dumpleton at gmail.com>
Subject: Re: [mod_python] Object cleanup with child process scaling
To: "Nicholas Milkovits" <nmilkovits at gmail.com>
Cc: mod_python at modpython.org
Message-ID:
	<88e286470703191357n4f49e44am479406632e0a2077 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 20/03/07, Nicholas Milkovits <nmilkovits at gmail.com> wrote:
> Hello all,
>
> I have a quick question about how apache2 and mod python work. When
> apache (running in prefork mode) decides to scale back the number of
> running child processes running because of a low request volume, does
> mod python ensure that all objects have their __del__ methods called

No it doesn't currently ensure that __del__ methods are called.

> or does apache just kill it and release the memory back to the system?

Yes and no. See below.

> I am running across a problem where my oracle db has to many sessions
> open (although they are marked as idle/invalid) and it appears to be
> because the client application is never explicity telling oracle to
> close the sessions before exiting. Is there any way to ensure a chunk
> of code gets run before apache kills the process?

When an Apache child process is killed the socket will be closed off.
The Oracle server side should detect this and recycle the connection
automatically. Because of this fact, I would suggest the problem might
lie elsewhere.

That said, look at the apache.register_cleanup() method.

  http://www.modpython.org/live/current/doc-html/pyapi-apmeth.html

This allows registration of callback to be called when Apache child
process is being shutdown. Note though that it is not guaranteed that
the callback will be called as various things could cause shutdown to
hang and parent Apache process will forcibly kill off child processes
if this occurs. Child process could also just die of their own accord
as well which would also mean that this would not be triggered.

Graham


------------------------------

Message: 3
Date: Tue, 20 Mar 2007 09:35:14 +0100
From: Gabriele Farina <g.farina at pharaondev.com>
Subject: [mod_python] Compiling mod_python
To: mod_python at modpython.org
Message-ID: <5EB03EC6-9F5B-4DDA-8AC1-8778161CA0EC at pharaondev.com>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed

Hi,

today I'm trying to compile mod_python on a Debian Linux box.
I installed correctly apache 2.2.4 and Python 2.5 from sources and  
then tried to compile mod_python. I get this error:

...
/config -Xlinker -export-dynamic -lm -lpython2.5 -lpthread -ldl - 
lutil -lm
/usr/bin/ld: /usr/local/lib/python2.5/config/libpython2.5.a 
(abstract.o): relocation R_X86_64_32 against `a local symbol' can not  
be used when making a shared object; recompile with -fPIC
/usr/local/lib/python2.5/config/libpython2.5.a: could not read  
symbols: Bad value
collect2: ld returned 1 exit status
apxs:Error: Command failed with rc=65536
.
make[1]: *** [mod_python.so] Error 1
make[1]: Leaving directory `/usr/local/src/mod_python-3.3.1/src'
make: *** [do_dso] Error 2

Anyone can help me understand where is the problem ?

Gabriele



------------------------------

Message: 4
Date: Tue, 20 Mar 2007 04:44:39 -0400
From: Roberto C. S?nchez <roberto at connexer.com>
Subject: Re: [mod_python] Compiling mod_python
To: Gabriele Farina <g.farina at pharaondev.com>
Cc: mod_python at modpython.org
Message-ID: <20070320084439.GB8104 at santiago.connexer.com>
Content-Type: text/plain; charset="iso-8859-1"

On Tue, Mar 20, 2007 at 09:35:14AM +0100, Gabriele Farina wrote:
> Hi,
> 
> today I'm trying to compile mod_python on a Debian Linux box.
> I installed correctly apache 2.2.4 and Python 2.5 from sources and  
> then tried to compile mod_python. I get this error:
> 
Umm, why on Earth would you install Apache *and* Python from sources on
Debian?  Just use aptitude.  Besides, mod_python is also packaged for
Debian.

Regards,

-Roberto

-- 
Roberto C. Sánchez
http://people.connexer.com/~roberto
http://www.connexer.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20070320/c5973d52/attachment-0001.bin

------------------------------

Message: 5
Date: Tue, 20 Mar 2007 21:27:45 +1100
From: "Graham Dumpleton" <graham.dumpleton at gmail.com>
Subject: Re: [mod_python] Compiling mod_python
To: " Roberto C. S?nchez " <roberto at connexer.com>,	"Gabriele Farina"
	<g.farina at pharaondev.com>, mod_python at modpython.org
Message-ID:
	<88e286470703200327n31c2eba6t46f320effad6b790 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 20/03/07, Roberto C. Sánchez <roberto at connexer.com> wrote:
> On Tue, Mar 20, 2007 at 09:35:14AM +0100, Gabriele Farina wrote:
> > Hi,
> >
> > today I'm trying to compile mod_python on a Debian Linux box.
> > I installed correctly apache 2.2.4 and Python 2.5 from sources and
> > then tried to compile mod_python. I get this error:
> >
> Umm, why on Earth would you install Apache *and* Python from sources on
> Debian?  Just use aptitude.  Besides, mod_python is also packaged for
> Debian.

One reason for recompiling Python is because the prepackaged binary
distributions of Python are generally never built with the
--enabled-shared option. This means you only have a static libpython.a
file and on 64 bit platforms when recompiling mod_python like above
this presents problems sometimes as Python packages are only built as
32 bit binaries. Also, that there is only a static libpython.a and not
a libpython.so means that the static Python library has to be embedded
within the mod_python.so file to work. This means that instead of your
mod_python.so being in the order of a few hundred KBytes it is over
1MB in size. Because the Python library part of this is not
relocatable object files, when it gets loaded into memory it
potentially has to have address relocations done on it resulting in
the mod_python.so no longer being shared between processes and instead
each of your Apache child processes ends up with up to 1.5MB of extra
private memory in use. In the end your Python web application is going
to probably take a lot more memory than that but it doesn't make the
situation any better.

Thus, to the OP, rebuild your Python installation from source first
and ensure that --enable-shared is used when configure is run. After
you have that reinstalled, then try rebuilding mod_python and see if
the error goes away. To save trashing the existing Python installation
you might install new version of Python elsewhere. Be warned that you
may have to ensure location of  'python' executable for new version is
in PATH before standard one for user that Apache runs as. See how it
goes without doing that first though. Not sure if rebuilding Apache is
actually necessary.

Graham



------------------------------

Message: 6
Date: Tue, 20 Mar 2007 08:32:58 -0500
From: Kenneth Loafman <kenneth at loafman.com>
Subject: [mod_python] Detecting Back Button Usage
To: Mod_python at modpython.org
Message-ID: <45FFE28A.7010104 at loafman.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi,

This may not be the list I need, but here goes.  I'm new at this whole 
user interface thing, by nature a low-level systems guy, so be kind.

I'm using mod_python under Ubuntu Edgy 64, doing some basic plots of 
data and allowing users to select a point to center on a region and gen 
the next plot.  All of that works as long as the user moves forward. 
The problem comes in the use of the back button.  The browser merely 
displays the last page rather than rebuilding it, or at least restoring 
the variables.  This leads to a lot of confusion because the server is 
on one set of plot values and the browser is now on another.  This seems 
to be a common problem.  Is there a solution, or should I just warn the 
user not to use the browser back button?

...Thanks,
...Ken


------------------------------

Message: 7
Date: Tue, 20 Mar 2007 11:03:05 -0300
From: Clodoaldo <clodoaldo.pinto.neto at gmail.com>
Subject: Re: [mod_python] Detecting Back Button Usage
To: "Kenneth Loafman" <kenneth at loafman.com>
Cc: Mod_python at modpython.org
Message-ID:
	<a595de7a0703200703m1e43c581y78990bd71d511166 at mail.gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed

2007/3/20, Kenneth Loafman <kenneth at loafman.com>:
> I'm using mod_python under Ubuntu Edgy 64, doing some basic plots of
> data and allowing users to select a point to center on a region and gen
> the next plot.  All of that works as long as the user moves forward.
> The problem comes in the use of the back button.  The browser merely
> displays the last page rather than rebuilding it, or at least restoring
> the variables.  This leads to a lot of confusion because the server is
> on one set of plot values and the browser is now on another.  This seems
> to be a common problem.  Is there a solution, or should I just warn the
> user not to use the browser back button?

How does the user select the point? Entering it in a form field? If so
save the plot values (the page state) on the page using a hidden field
inside the form:
<input type="hidden" name="variable_1" value="99.9">
<input type="hidden" name="variable_2" value="33.3">

When the form is submitted those values will be available to your script.

If you are using some Ajax scripting to let the user select the point
then adapt it to also send the current page state.

I could not find the correct words to google. It would be something
like "page state maintenance in HTML (or HTTP)". Can someone create
the correct search words?

Regards,
-- 
Clodoaldo Pinto Neto


------------------------------

Message: 8
Date: Tue, 20 Mar 2007 10:03:30 -0400
From: Jorey Bump <list at joreybump.com>
Subject: Re: [mod_python] Detecting Back Button Usage
To: Kenneth Loafman <kenneth at loafman.com>
Cc: Mod_python at modpython.org
Message-ID: <45FFE9B2.7040300 at joreybump.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Kenneth Loafman wrote:
> Hi,
> 
> This may not be the list I need, but here goes.  I'm new at this whole 
> user interface thing, by nature a low-level systems guy, so be kind.
> 
> I'm using mod_python under Ubuntu Edgy 64, doing some basic plots of 
> data and allowing users to select a point to center on a region and gen 
> the next plot.  All of that works as long as the user moves forward. The 
> problem comes in the use of the back button.  The browser merely 
> displays the last page rather than rebuilding it, or at least restoring 
> the variables.  This leads to a lot of confusion because the server is 
> on one set of plot values and the browser is now on another.  This seems 
> to be a common problem.  Is there a solution, or should I just warn the 
> user not to use the browser back button?

By default, your application has no way of knowing how the client 
requested the URL (other than the unreliable HTTP_REFERER environment 
variable), so it will need to know how to handle all requests, no matter 
what. You can maintain/simulate some sort of state in a variety of 
(somewhat limited) ways on the server side, and everyone has their own 
favorite approach. In any case, you need to expect the unexpected in the 
application itself.

After securing your application, you can add client-side scripting for 
potentially finer control over the requests sent by the client under 
certain circumstances. Typically, you'll use JavaScript, but there are 
other options, depending on your needs. Be aware that while you can 
require that your users depend on this to get use from your application, 
you can't force an arbitrary client to follow such rules, so you do need 
to be prepared when a visitor arrives without JavaScript enabled (for 
example).

Since you're correct that this isn't a mod_python issue, you're most 
likely to get more useful answers in a JavaScript or DHTML forum. There 
are also a number of JavaScript frameworks springing up, due to the AJAX 
craze, and some of these might have useful libraries, so you don't have 
to reinvent the wheel.



------------------------------

Message: 9
Date: Tue, 20 Mar 2007 10:30:19 -0400
From: Jorey Bump <list at joreybump.com>
Subject: Re: [mod_python] Detecting Back Button Usage
To: Clodoaldo <clodoaldo.pinto.neto at gmail.com>
Cc: Mod_python at modpython.org
Message-ID: <45FFEFFB.5030208 at joreybump.com>
Content-Type: text/plain; charset=UTF-8; format=flowed

Clodoaldo wrote:
> 2007/3/20, Kenneth Loafman <kenneth at loafman.com>:
>> The problem comes in the use of the back button.  The browser merely
>> displays the last page rather than rebuilding it, or at least restoring
>> the variables.  
> 
> How does the user select the point? Entering it in a form field? If so
> save the plot values (the page state) on the page using a hidden field
> inside the form:
> <input type="hidden" name="variable_1" value="99.9">
> <input type="hidden" name="variable_2" value="33.3">
> 
> When the form is submitted those values will be available to your script.

These days, all bets are off concerning the default behaviour of the 
back button on the variety of browsers one will encounter. There's no 
way to enforce sending form variables without client side scripting...

> If you are using some Ajax scripting to let the user select the point
> then adapt it to also send the current page state.

...as you suggest here. Even so, exhaustive testing is recommended 
before you assume it works for all browsers, as well as preparing for 
browsers with DHTML features disabled or crippled. The most foolproof 
design will maintain state on the server, perhaps using a database. It's 
  a lot of work up front, but has a number of payoffs, as long as the 
application warrants it. Of course, since the OP seems to be describing 
a graphical application, he may get a lot of mileage out of AJAX or 
something like it.


------------------------------

_______________________________________________
Mod_python mailing list
Mod_python at modpython.org
http://mailman.modpython.org/mailman/listinfo/mod_python


End of Mod_python Digest, Vol 48, Issue 23
******************************************



More information about the Mod_python mailing list