Skip to content

Commit 52c5788

Browse files
committed
launch multiprocessing programs without in python mode
1 parent d333fda commit 52c5788

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

examples/multiprocessing_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
An undecorated example of a script that allocates memory in multiprocessing
33
workers 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
66
You can then visualize the usage with mprof plot.
77
"""
88

mprof

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff 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"):

0 commit comments

Comments
 (0)