16 # but use tcmalloc by default if TCMALLOCDIR is defined
17 if [ -n "$TCMALLOCDIR" ]; then
21 # parse LD_PRELOAD related command line arguments
25 --leak-check*) USETCMALLOC=0;;
26 --delete-check*) USETCMALLOC=0;;
27 --stdcmalloc) USETCMALLOC=0;;
28 --tcmalloc) USETCMALLOC=1;;
29 --stdcmath) USEIMF=0;;
31 --exctrace) USEEXCTRACE=1;;
32 --no-excabort) USEEXCABORT=0;;
33 --preloadlib*) export ATHENA_ADD_PRELOAD=${a#*=};;
34 --drop-and-reload) ATHENA_DROP_RELOAD=1;;
35 *) otherargs+=("$a");;
40 # Do the actual preloading via LD_PRELOAD and save the original value
41 export LD_PRELOAD_ORIG=${LD_PRELOAD}
42 source `which athena_preload.sh `
44 # Now resurrect ourselves as python script
45 python_path=`which python`
46 "exec" "$python_path" "-tt" "$0" "$@";
80 __author__ =
'Wim Lavrijsen (WLavrijsen@lbl.gov)'
81 __doc__ =
'For details about athena.py, run "less `which athena.py`"'
86 import AthenaCommon.AthOptionsParser
as aop
87 aop.enable_athenaCLI()
88 opts = aop.parse(legacy_args=
True)
92 from AthenaCommon.Utils.unixtools
import FindFile
93 path_list = [
'./'] + os.environ.get(
'PYTHONPATH',
'').
split(os.pathsep)
94 file_path =
FindFile( os.path.expanduser( os.path.expandvars(opts.scripts[0]) ),
97 if file_path
is not None:
98 with open(file_path)
as f:
99 if f.readline().startswith(
'#!'):
103 sys.argv.remove(opts.scripts[0])
104 opts.scripts[0] = file_path
108 with open(opts.fromdb,
'rb')
as f:
111 opts.CA =
not isinstance(acc, dict)
114 except ModuleNotFoundError:
118 if 'LD_PRELOAD_ORIG' in os.environ:
119 os.environ[
'LD_PRELOAD'] = os.getenv(
'LD_PRELOAD_ORIG')
120 os.unsetenv(
'LD_PRELOAD_ORIG')
123 from AthenaCommon.Debugging
import DbgStage
124 DbgStage.value = opts.debug
127 if not os.getcwd()
in sys.path:
128 sys.path = [ os.getcwd() ] + sys.path
130 if '' not in sys.path:
131 sys.path = [
'' ] + sys.path
140 from ctypes.util
import find_library
as ctypes_find_library
141 libc = ctypes.cdll.LoadLibrary( ctypes_find_library(
'c') )
142 libc.prctl( 15, b
'athena.py', 0, 0, 0 )
148 if not (opts.interactive
or opts.debug):
150 if sys.stdin
and os.isatty( sys.stdin.fileno() ):
151 os.close( sys.stdin.fileno() )
160 from AthenaCommon
import ExitCodes
164 if not opts.tracelevel:
166 runpy.run_path( opts.scripts[0], run_name=
'__main__' )
168 from AthenaCommon.Debugging
import traceExecution
172 from AthenaCommon.AthOptionsParser
import configureCAfromArgs
174 sys.exit(acc.run(opts.evtMax).isFailure())
176 except SystemExit
as e:
178 exitcode = ExitCodes.EXE_ALG_FAILURE
if e.code==1
else e.code
180 from AthenaCommon
import Logging
181 Logging.log.info(
'leaving with code %d: "%s"',
182 exitcode, ExitCodes.what(exitcode) )
188 from AthenaCommon.Logging
import logging, log
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" )