17# but use tcmalloc by default if TCMALLOCDIR is defined
18if [ -n "$TCMALLOCDIR" ]; then
22# parse LD_PRELOAD related command line arguments
26 --stdcmalloc) USETCMALLOC=0;USEJEMALLOC=0;;
27 --tcmalloc) USETCMALLOC=1;USEJEMALLOC=0;;
28 --jemalloc) USETCMALLOC=0;USEJEMALLOC=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
41export LD_PRELOAD_ORIG=${LD_PRELOAD}
42source `which athena_preload.sh `
44# Now resurrect ourselves as python script
45python_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`"'
86import AthenaCommon.AthOptionsParser
as aop
88opts = aop.parse(legacy_args=
True)
91from PyUtils.Helpers
import ROOTSetup
92ROOTSetup(batch =
not opts.interactive)
96 from AthenaCommon.Utils.unixtools
import FindFile
97 path_list = [
'./'] + os.environ.get(
'PYTHONPATH',
'').
split(os.pathsep)
98 file_path = FindFile( os.path.expanduser( os.path.expandvars(opts.scripts[0]) ),
101 if file_path
is not None:
102 with open(file_path)
as f:
103 if f.readline().startswith(
'#!'):
107 sys.argv.remove(opts.scripts[0])
108 opts.scripts[0] = file_path
112 with open(opts.fromdb,
'rb')
as f:
115 opts.CA =
not isinstance(acc, dict)
118 except ModuleNotFoundError:
122if 'LD_PRELOAD_ORIG' in os.environ:
123 os.environ[
'LD_PRELOAD'] = os.getenv(
'LD_PRELOAD_ORIG')
124 os.unsetenv(
'LD_PRELOAD_ORIG')
127from AthenaCommon.Debugging
import DbgStage
128DbgStage.value = opts.debug
131if not os.getcwd()
in sys.path:
132 sys.path = [ os.getcwd() ] + sys.path
134if '' not in sys.path:
135 sys.path = [
'' ] + sys.path
144 from ctypes.util
import find_library
as ctypes_find_library
145 libc = ctypes.cdll.LoadLibrary( ctypes_find_library(
'c') )
146 libc.prctl( 15, b
'athena.py', 0, 0, 0 )
152if not (opts.interactive
or opts.debug):
154 if sys.stdin
and os.isatty( sys.stdin.fileno() ):
155 os.close( sys.stdin.fileno() )
164 from AthenaCommon
import ExitCodes
168 if not opts.tracelevel:
170 runpy.run_path( opts.scripts[0], run_name=
'__main__' )
172 from AthenaCommon.Debugging
import traceExecution
173 traceExecution( opts.scripts[0], opts.tracelevel )
176 from AthenaCommon.AthOptionsParser
import configureCAfromArgs
177 configureCAfromArgs( acc, opts )
178 sys.exit(acc.run(opts.evtMax).isFailure())
180 except SystemExit
as e:
182 exitcode = ExitCodes.EXE_ALG_FAILURE
if e.code==1
else e.code
184 from AthenaCommon
import Logging
185 Logging.log.info(
'leaving with code %d: "%s"',
186 exitcode, ExitCodes.what(exitcode) )
192 from AthenaCommon.Logging
import logging, log
197 _msg.setLevel (getattr(logging, opts.loglevel))
202 if opts.profile_python:
207 cProfile._athena_python_profiler = cProfile.Profile()
208 cProfile._athena_python_profiler.enable()
211 aop.fill_athenaCommonFlags(opts)
214 from AthenaCommon.Include
import include
215 include.setShowIncludes(opts.showincludes)
218 include(
"AthenaCommon/Preparation.py" )
221 include(
"AthenaCommon/Execution.py" )
std::vector< std::string > split(const std::string &s, const std::string &t=":")