15 # but use tcmalloc by default if TCMALLOCDIR is defined
16 if [ -n "$TCMALLOCDIR" ]; then
20 # parse LD_PRELOAD related command line arguments
24 --leak-check*) USETCMALLOC=0;;
25 --delete-check*) USETCMALLOC=0;;
26 --stdcmalloc) USETCMALLOC=0;;
27 --tcmalloc) USETCMALLOC=1;;
28 --stdcmath) USEIMF=0;;
30 --exctrace) USEEXCTRACE=1;;
31 --preloadlib*) export ATHENA_ADD_PRELOAD=${a#*=};;
32 --drop-and-reload) ATHENA_DROP_RELOAD=1;;
33 *) otherargs+=("$a");;
38 # Do the actual preloading via LD_PRELOAD and save the original value
39 export LD_PRELOAD_ORIG=${LD_PRELOAD}
40 source `which athena_preload.sh `
42 # Now resurrect ourselves as python script
43 python_path=`which python`
44 "exec" "$python_path" "-tt" "$0" "$@";
78 __author__ =
'Wim Lavrijsen (WLavrijsen@lbl.gov)'
79 __doc__ =
'For details about athena.py, run "less `which athena.py`"'
84 import AthenaCommon.AthOptionsParser
as aop
85 aop.enable_athenaCLI()
86 opts = aop.parse(legacy_args=
True)
90 from AthenaCommon.Utils.unixtools
import FindFile
91 path_list = [
'./'] + os.environ.get(
'PYTHONPATH',
'').
split(os.pathsep)
92 file_path =
FindFile( os.path.expanduser( os.path.expandvars(opts.scripts[0]) ),
95 if file_path
is not None:
96 with open(file_path)
as f:
97 if f.readline().startswith(
'#!'):
101 sys.argv.remove(opts.scripts[0])
102 opts.scripts[0] = file_path
106 with open(opts.fromdb,
'rb')
as f:
109 opts.CA =
not isinstance(acc, dict)
112 except ModuleNotFoundError:
116 if 'LD_PRELOAD_ORIG' in os.environ:
117 os.environ[
'LD_PRELOAD'] = os.getenv(
'LD_PRELOAD_ORIG')
118 os.unsetenv(
'LD_PRELOAD_ORIG')
121 from AthenaCommon.Debugging
import DbgStage
122 DbgStage.value = opts.debug
125 if not os.getcwd()
in sys.path:
126 sys.path = [ os.getcwd() ] + sys.path
128 if '' not in sys.path:
129 sys.path = [
'' ] + sys.path
138 from ctypes.util
import find_library
as ctypes_find_library
139 libc = ctypes.cdll.LoadLibrary( ctypes_find_library(
'c') )
140 libc.prctl( 15, b
'athena.py', 0, 0, 0 )
146 if not (opts.interactive
or opts.debug):
148 if sys.stdin
and os.isatty( sys.stdin.fileno() ):
149 os.close( sys.stdin.fileno() )
158 from AthenaCommon
import ExitCodes
162 if not opts.tracelevel:
164 runpy.run_path( opts.scripts[0], run_name=
'__main__' )
166 from AthenaCommon.Debugging
import traceExecution
170 from AthenaCommon.AthOptionsParser
import configureCAfromArgs
172 sys.exit(acc.run(opts.evtMax).isFailure())
174 except SystemExit
as e:
176 exitcode = ExitCodes.EXE_ALG_FAILURE
if e.code==1
else e.code
182 print(
'leaving with code %d: "%s"' % (exitcode, ExitCodes.what(exitcode)) )
193 _msg.setLevel (getattr(logging, opts.loglevel))
198 if opts.profile_python:
203 cProfile._athena_python_profiler = cProfile.Profile()
204 cProfile._athena_python_profiler.enable()
207 aop.fill_athenaCommonFlags(opts)
210 from AthenaCommon.Include
import include
211 include.setShowIncludes(opts.showincludes)
214 include(
"AthenaCommon/Preparation.py" )
217 include(
"AthenaCommon/Execution.py" )