Loading required libraries for python script from shell just once

raviforlkml at gmail.com raviforlkml at gmail.com
Mon Dec 1 20:48:22 EST 2008


I have a linux-like host running busybox with the python installation
mounted over NFS and have the corresponding symlinks setup in /usr/bin
and /usr/lib for python to run smoothly.

A shell script runs my python script several times, each time with
different paramters. E.g.

# cat foo.sh

# Lot of setup stuff

${TEST_DIR}/bin/run-test.py --arg1 foo1 --arg2 bar1 --arg3 baz1
${TEST_DIR}/bin/run-test.py --arg1 foo2 --arg2 bar2 --arg3 baz2
${TEST_DIR}/bin/run-test.py --arg1 foo3 --arg2 bar3 --arg3 baz3


There is a delay of about 10-15 seconds before run-test.py starts
executing. Can someone suggest a method to speed up this process? Most
of the delay seems to be due to python loading up the required
modules. Is it possible to load all the modules used by run-test.py in
a pre-execution environment in order to prevent this delay?

I considered a rewrite of the shell script into python, but it has too
many dependencies on shell libraries and I don't want to go that route
(unless an alternative solution is impossible).

Thanks!



More information about the Python-list mailing list