Hi, 

I'm having issues using subprocess.call from within a module file in 
web2py. My code is something like

import shlex
import subprocess

# This is a command to call the imagemagick convert function
cmd_string = 'convert 
"/home/www-data/web2py/applications/subway_art_dev/modules/a_temp/tmp521932.png"
 
-trim -thumbnail "2700x3600>" -background "white" -gravity "center" -extent 
2700x3600   
"/home/www-data/web2py/applications/subway_art_dev/modules/a_temp/tmp680852.png"'

subprocess.check_call(shlex.split(cmd_string))

with open('log.txt', 'a') as f:
f.write('got this far')
This code works fine if I execute it in a python shell, but fails for some 
reason when I call it in web2py. It never gets as far as writing to the log 
file, but so far as I can tell check_call doesn't raise a 
CalledProcessError exception either. The web page corresponding to the 
controller function that calls the module just hangs. 

The funny thing is that if I use an imagemagick command that's faster to 
run (e.g. a lower resolution image) then it works fine. It's only once the 
command is so long that it takes about 5 seconds or more that it starts 
failing when called from within web2py.

Any advice on what's going wrong and what to do? I tried using os.system 
instead but it doesn't work either. I'm running web2py 2.9.5 with nginx on 
ubuntu 13. It's crossed my mind that nginx might be shutting down the 
subprocess when it runs too long, but I don't know how to check that.

Thanks in advance for any advice,

Toby

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to