Re: mod_wsgi and SIGTERM or SIGKILL

61 views
Skip to first unread message

Dalius Dobravolskas

unread,
Feb 22, 2009, 4:39:17 PM2/22/09
to Graham Dumpleton, mod...@googlegroups.com
Hello, Graham,

OK. I will use modwsgi group.

Answers to your questions:

My wsgi program executes "pypy-c" program in separate process.

I was trying to use both embedded and daemon modes. Config is very simple:

<VirtualHost *>
ServerName py.sandbox.lt
ServerAdmin dal...@sandbox.lt
ServerSignature Off
AddDefaultCharset utf-8

CustomLog /var/log/apache2/py-access.log combined
ErrorLog /var/log/apache2/py-error.log
LogLevel info

WSGIScriptAlias / /home/dalius/wsgi/py.wsgi
</VirtualHost>

py.wsgi looks like this:

from pypysandboxserver import PyPyApp
application = PyPyApp()

That's very pure and basic wsgi application. I will try version 2.X with
daemon mode and will report result.

Thank you for very quick answer.

Regards,
Dalius

Graham Dumpleton wrote:
> Is the PyPy stuff run within the Apache/mod_wsgi process, or does it
> execute as a separate process form the Apache/mod_wsgi process which
> you then communicate with? Further, are you using embedded mode or
> daemon mode of mod_wsgi?
>
> If the process is being exec'd and using daemon mode, then probably:
>
> http://code.google.com/p/modwsgi/issues/detail?id=87
>
> Try patch or just use version from 2.X branch out of subversion:
>
> http://code.google.com/p/modwsgi/wiki/ChangesInVersion0204
>
> If not, will need to be clearer about mod_wsgi configuration being
> used and whether or not PyPy stuff is a separate process.
>
> BTW, appreciated if can use mod_wsgi list on Google Groups. That was
> conversation archived and answer can help someone else.
>
> Graham
>
> 2009/2/23 Dalius Dobravolskas <dalius.do...@gmail.com>:
>
>> Hello, Graham,
>>
>> I have problem with mod_wsgi (or most probably with Apache) and I think you
>> are the person who could answer me.
>>
>> I was experimenting with PyPy sandboxing and have written simple WSGI
>> program (see attachment if that helps to understand the problem). That
>> program basically does very simple thing: you write python code and program
>> executes it (using PyPy sandboxed interpreter). That's it. You can look at
>> this program running here http://py.sandbox.lt (behind mod_wsgi of course
>> ;-)).
>>
>> My problem is following: since I don't want my server to be abused or reused
>> as cheap computational power (that server runs several websites) I have
>> limited process to 5 seconds. In PyPy code process is terminated with
>> SIGTERM. The problem is that SIGTERM does not terminate PyPy process. I have
>> checked I can't kill process with simple kill command as well. Process can
>> be terminated only with SIGKILL.
>>
>> I have modified the code to use SIGKILL and that fits my needs but...
>> 1) I don't care too much here is process is SIGTERMed or SIGKILLed but maybe
>> I should?
>> 2) Is there way to use SIGTERM here?
>>
>> I have found some information in mod_wsgi documenation about signals and
>> Apache and tried experimenting with some mod_wsgi options but that does not
>> make any difference.
>>
>> Regards,
>> Dalius
>>
>>

Dalius Dobravolskas

unread,
Feb 23, 2009, 6:13:20 AM2/23/09
to mod...@googlegroups.com
On Sun, Feb 22, 2009 at 11:20 PM, Graham Dumpleton
<graham.d...@gmail.com> wrote:
> Try patch or just use version from 2.X branch out of subversion:
>
> http://code.google.com/p/modwsgi/wiki/ChangesInVersion0204
I have tried to use this version. SIGTERM still does not work. Only SIGKILL.

--
Dalius
http://blog.sandbox.lt

Graham Dumpleton

unread,
Feb 23, 2009, 6:19:46 AM2/23/09
to mod...@googlegroups.com
2009/2/23 Dalius Dobravolskas <dalius.do...@gmail.com>:

>
> On Sun, Feb 22, 2009 at 11:20 PM, Graham Dumpleton
> <graham.d...@gmail.com> wrote:
>> Try patch or just use version from 2.X branch out of subversion:
>>
>> http://code.google.com/p/modwsgi/wiki/ChangesInVersion0204
> I have tried to use this version. SIGTERM still does not work. Only SIGKILL.

While I think of something more intelligent to say, in your code you have:

page = """ ....."""

return page

Thus, returning string from WSGI application. This is very
inefficient. Result should be an iterable, which string qualifies as,
but end result will be that single character is flush at a time. Use
instead:

return [page]

Graham

Graham Dumpleton

unread,
Feb 23, 2009, 6:37:09 AM2/23/09
to mod...@googlegroups.com
Nothing more intelligent at this point. I will need to run a test with
pypy myself to work it out. I have looked through pypy sandbox code a
bit and at least understand what you are talking about. Going to be a
busy day tomorrow, but if lucky may get a chance to look at it in the
evening.

Graham

2009/2/23 Graham Dumpleton <graham.d...@gmail.com>:

Dalius

unread,
Feb 23, 2009, 8:59:29 AM2/23/09
to modwsgi
Hello, Graham,

It takes some time to compile pypy sandbox. I have pypy-c compiled for
Debian Etch (4.0) and Ubuntu 8.10. If you are using on of these
systems I can send you compiled binaries to you so you can save some
time.

Thank you for looking into this issue.

Dalius

On Feb 23, 1:37 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:

Dalius

unread,
Feb 23, 2009, 9:40:05 AM2/23/09
to modwsgi
> >  http://code.google.com/p/modwsgi/wiki/ChangesInVersion0204
> I have tried to use this version. SIGTERM still does not work. Only SIGKILL.
Correction!

SIGTERM works with 2.X and daemon mode. It is not working with
embedded mode only.

My head works bad today...

Regards,
Dalius

Graham Dumpleton

unread,
Feb 23, 2009, 5:45:35 PM2/23/09
to mod...@googlegroups.com
2009/2/24 Dalius <dalius.do...@gmail.com>:

>
>> > http://code.google.com/p/modwsgi/wiki/ChangesInVersion0204
>> I have tried to use this version. SIGTERM still does not work. Only SIGKILL.
> Correction!
>
> SIGTERM works with 2.X and daemon mode. It is not working with
> embedded mode only.

If it works on daemon mode, would expect it to work in embedded mode.

Which MPM is Apache configured to use? Are you running other web
application modules in Apache such as PHP?

Graham

Dalius

unread,
Feb 24, 2009, 1:09:53 AM2/24/09
to modwsgi
On Feb 24, 12:45 am, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> Which MPM is Apache configured to use?
mpm_worker

> Are you running other web application modules in Apache such as PHP?
No other web applications modules. This server is very minimalist.
Here is `ls` output from mods-enabled:

alias.load authz_user.load dir.conf rewrite.load
auth_basic.load autoindex.load dir.load setenvif.load
authn_file.load cgid.conf env.load status.load
authz_default.load cgid.load mime.load
authz_groupfile.load deflate.conf modwsgi.load
authz_host.load deflate.load negotiation.load

I have tested this in two servers (my dev and production) with same
result:
Server version: Apache/2.2.3
Server built: Jan 27 2008 18:09:58

Server version: Apache/2.2.9 (Ubuntu)
Server built: Sep 19 2008 13:45:10

Regards,
Dalius

Dalius

unread,
Feb 27, 2009, 5:51:23 AM2/27/09
to modwsgi
Hello, Graham,

On Feb 24, 12:45 am, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> >> >  http://code.google.com/p/modwsgi/wiki/ChangesInVersion0204
> >> I have tried to use this version. SIGTERM still does not work. Only SIGKILL.
> > Correction!
>
> > SIGTERM works with 2.X and daemon mode. It is not working with
> > embedded mode only.
>
> If it works on daemon mode, would expect it to work in embedded mode.
Since you have asked to confirm this I can confirm it one more time:
SIGTERM works only in daemon mode. That's not problem for me but other
might meet this problem in different situation.

mod_wsgi 2.X at revision 1210.

Regards,
Dalius
Reply all
Reply to author
Forward
0 new messages