파이썬 trace 모듈을 사용하면 프로그램 실행을 추적 할 수 있습니다. 개별적으로 각 프로세스의 추적을 저장하려면, 당신은 함수에 코드를 포장해야합니다 다음
def my_program(*args, **kwargs):
# insert your code here
pass
을 그리고 trace.Trace.runfunc
그것을 실행
import sys
import trace
# define Trace object: trace line numbers at runtime, exclude some modules
tracer = trace.Trace(
ignoredirs=[sys.prefix, sys.exec_prefix],
ignoremods=[
'inspect', 'contextlib', '_bootstrap',
'_weakrefset', 'abc', 'posixpath', 'genericpath', 'textwrap'
],
trace=1,
count=0)
# by default trace goes to stdout
# redirect to a different file for each processes
sys.stdout = open('trace_{:04d}.txt'.format(COMM_WORLD.rank), 'w')
tracer.runfunc(my_program)
를 이제 각 프로세스의 추적이 될 것입니다 별도의 파일 trace_0001.txt
등으로 작성하십시오. 하위 레벨 호출을 생략하려면 및 ignoremods
인수를 사용하십시오.