[pypy-dev] pypy sandbox

Dalius Dobravolskas dalius.dobravolskas at gmail.com
Fri Feb 20 07:30:32 CET 2009


>> I will try to implement WSGI sample similar to Django (as mentioned
>> here
>> http://morepypy.blogspot.com/2009/02/wroclaw-2009-sprint-progress-report.html).
> that's cool. Please keep us informed, and feel free to come to #pypy on
> irc.freenode.net if you have any question.

Here is result: http://py.sandbox.lt/

Basically it is the same code as Django example but only written in
WSGI (I will share that later).

Here some of my experiences that I think I should mention:

1. I'm running my code behind Apache mod_wsgi. As you might know
mod_wsgi is very strict WSGI implementation. pypy_interact failed when
was calling isatty function (mod_wsgi.Log does not have this
function). I have fixed that by adding "'isatty in dir(log)". I will
give later exact locations and names if I have confused them.

2. It looks like that PyPySandboxedProc expects --heapsize as first
argument in argument list.

3. Is settimeout actually working? If I run following code (please
don't run it on my server):

x = 1
for y in xrange(1, 1024*1024):
     x *= y
print x

Process is not terminated after one second and uses significant part
of my CPU resources. I set timeout in following way:

sandproc = pypy_interact.PyPySandboxedProc(SANDBOX_BIN, ['--heapsize',
str(1024*1024), '-c', code])
sandproc.settimeout(1, interrupt_main=True)

I have tried 5 seconds as well. I will analyze the code myself a
little bit but if you have ideas already please share them ;-)


More information about the Pypy-dev mailing list