solaris - Memory efficient calling of external command in Python -
i have python script needs load lot's of data calling lot's of external commands. after couple hours crashes this:
.... process = subprocess.popen(cmd, stdout=subprocess.pipe, stderr=subprocess.pipe, close_fds=true) file "/usr/lib/python2.6/subprocess.py", line 621, in __init__ errread, errwrite) file "/usr/lib/python2.6/subprocess.py", line 1037, in _execute_child self.pid = os.fork() oserror: [errno 12] not enough space abort: not enough space
... though machine have more memory available script using.
the root cause seems every fork() requires twice memory parent process released calling of exec() (see: http://www.oracle.com/technetwork/server-storage/solaris10/subprocess-136439.html) ... in case above worse because i'm loading data in multiple threads.
so see creative way how workaround issue?
do need launch external command or fork 1 you're running?
if need run script try:
subprocess.call()
i.e.
subprocess.call(["ls", "-l"])
the os.fork copies current environment might unnecessary depending on usage.
don't forget import subprocess module before using it.
Comments
Post a Comment