See prior discussion:
http://groups.google.com/group/modwsgi/browse_frm/thread/d2dd16fe291363ee
That person was unable to give me a good enough explanation to
understand how pdftk worked and why it could be the issues with
signals he claimed it was.
In the end he just went away and we never knew if he solved it or not.
If you can try and explain as much as possible about how pdftk works,
maybe this time we can work out what is going on.
Graham
As much as I can work out so far, I can't see how Apache and/or
mod_wsgi could be interfering with SIGPWR, especially since it is in
the context of a separately executed process. This is what made the
original persons claim not make too much sense.
> I'm not familiar enough with this stuff though. Let me know what kind
> of information you need, and some rough pointers on how to get it, and
> I'll me more than happy to help you help me!
>
> I figured out how to use the gdb - and ran the program through it... I
> don't see how this could help at all.. but what the heck:
>
> [New Thread 0xb6727b90 (LWP 25346)]
>
> Program received signal SIGPWR, Power fail/restart.
> [Switching to Thread 0xb6727b90 (LWP 25346)]
> 0xb7f1d410 in __kernel_vsyscall ()
> (gdb) c
> Continuing.
>
> Program received signal SIGXCPU, CPU time limit exceeded.
> 0xb7f1d410 in __kernel_vsyscall ()
> (gdb) c
> Continuing.
This is interesting though. Do you have CPU limits set on processes in any way?
> Program received signal SIGPWR, Power fail/restart.
> 0xb7f1d410 in __kernel_vsyscall ()
> (gdb) c
> Continuing.
>
> Program received signal SIGXCPU, CPU time limit exceeded.
> 0xb7f1d410 in __kernel_vsyscall ()
> (gdb) c
> Continuing.
>
> Program exited normally.
>
> I also tried registering a signal handler in my python function:
> import signal
> def handler(signum,frame):
> pass
> signal.signal(signal.SIGPWR, handler)
>
> But "signal only works in main thread" according to the exception it
> now throws. This is the first time I've ever dealt with signals in
> python, so I may be doing something stupid there :).
I'd be curious to see the exception message you are talking about.
The mod_wsgi package disables signal.signal() from doing anything and
logs a warning in Apache error logs. That is unless you disabled that
feature of mod_wsgi.
Graham
A guess at a way of checking is that with similar WSGI application
code, run a test Python script instead of pdftk. In that script have
it go into a loop which does a sleep of 1 second each time, up to a
maximum of 100 times so it eventually exits. Before you go into this
loop output process ID somewhere so can see it and then register
signal handlers to SIGPWR and SIGXCPU. Print out something from signal
handlers somewhere you can see it.
When request is handled and script run, find the pid of executed
script process and then send it SIGPWR and SIGXCPU to see if it
actually receives the signals or not. If not, then at start of script,
perhaps also dump out current sigmask for that process.
Graham
If you haven't already, tell me which operating system variant/version
you are using.
I'll try a similar test on MacOSX, but may take me a couple of days to
get myself setup to do that.
Graham
2008/6/4 Brennan <bren...@gmail.com>:
What mod_wsgi daemon mode does is block off signals so that they
aren't handled in the worker threads dealing with requests. Signals
are then waited upon and dealt with in main thread which also handles
ensuring process shutdown.
Problem is that the blocking of signals for the worker threads is
being inherited across a fork/exec which isn't what I expected.
Fixing this issue will be tricky and will need some rework of
mod_wsgi, with a movement away from relying solely on signals for
ensuring daemon process shutdown to a more complicated arrangement
using a pipe of death. I was looking at using a pipe of death anyway
as only safe way of doing things when introduce transient processes.
I will create an issue on mod_wsgi site for this. Sorry to say, it
will not be something that is addressed quickly. The only way around
it would be to write a C wrapper program for executing pdftk which
removes the blocks on those signals.
Graham
2008/6/5 Graham Dumpleton <graham.d...@gmail.com>: