File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22An undecorated example of a script that allocates memory in multiprocessing
33workers to demonstrate the use of memory_profiler with multiple processes.
44
5- Run this script with mprof run -M python multiprocessing_example.py
5+ Run this script with mprof run -M multiprocessing_example.py
66You can then visualize the usage with mprof plot.
77"""
88
Original file line number Diff line number Diff line change @@ -219,7 +219,15 @@ def run_action():
219219
220220 # .. TODO: more than one script as argument ? ..
221221 if args [0 ].endswith ('.py' ) and not options .nopython :
222- options .python = True
222+ if options .multiprocess and not args [0 ].startswith ("python" ):
223+ # in multiprocessing mode you want to spawn a separate
224+ # python process
225+ args .insert (0 , "python" )
226+ else :
227+ options .python = True
228+ if options .multiprocess :
229+ # multiprocess can't work in python mode
230+ options .python = False
223231 if options .python :
224232 print ("running as a Python program..." )
225233 if not args [0 ].startswith ("python" ):
You can’t perform that action at this time.
0 commit comments