8 __version__ =
'$Revision'
13 msg = logging.getLogger(__name__)
15 from PyJobTransforms.trfExeStepTools
import commonExecutorStepName
18 import PyJobTransforms.trfExceptions
as trfExceptions
25 athenaConcurrentEvents = 0
28 if legacyThreadingRelease:
29 return athenaMTThreads, athenaConcurrentEvents
33 if 'athenaopts' in argdict:
34 for substep
in argdict[
'athenaopts'].value:
35 if substep ==
'all' or substep == currentSubstep:
36 threadArg = [opt.replace(
"--threads=",
"")
for opt
in argdict[
'athenaopts'].value[substep]
if '--threads' in opt]
37 if len(threadArg) == 0:
39 elif len(threadArg) == 1:
40 if 'multithreaded' in argdict
and substep ==
'all':
41 raise ValueError(
"Detected conflicting methods to configure AthenaMT: --multithreaded and --threads=N (via athenaopts). Only one method must be used")
42 athenaMTThreads =
int(threadArg[0])
43 if athenaMTThreads < -1:
44 raise ValueError(
"--threads was set to a value less than -1")
46 raise ValueError(
"--threads was set more than once in 'athenaopts'")
47 if athenaMTThreads > 0:
48 msg.info(
'AthenaMT detected from "threads" setting with {0} threads for substep {1}'.
format(athenaMTThreads,substep))
50 concurrentEventsArg = [opt.replace(
"--concurrent-events=",
"")
for opt
in argdict[
'athenaopts'].value[substep]
if '--concurrent-events' in opt]
51 if len(concurrentEventsArg) == 1:
52 athenaConcurrentEvents =
int(concurrentEventsArg[0])
53 if athenaConcurrentEvents < -1:
54 raise ValueError(
"--concurrent-events was set to a value less than -1")
55 msg.info(
'Custom concurrent event setting read from "concurrent-events" with {0} events for substep {1}'.
format(athenaConcurrentEvents,substep))
57 athenaConcurrentEvents = athenaMTThreads
58 if (athenaMTThreads == 0
and
59 'ATHENA_CORE_NUMBER' in os.environ
and
60 'multithreaded' in argdict
and argdict[
'multithreaded'].value):
61 athenaMTThreads =
int(os.environ[
'ATHENA_CORE_NUMBER'])
62 if athenaMTThreads < -1:
63 raise ValueError(
"ATHENA_CORE_NUMBER value was less than -1")
64 msg.info(
'AthenaMT detected from ATHENA_CORE_NUMBER with {0} threads'.
format(athenaMTThreads))
65 athenaConcurrentEvents = athenaMTThreads
66 except ValueError
as errMsg:
67 myError =
'Problem discovering AthenaMT setup: {0}'.
format(errMsg)
70 return athenaMTThreads, athenaConcurrentEvents