Skip to content

Commit

Permalink
launch multiprocessing programs without in python mode
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianp committed Mar 21, 2017
1 parent d333fda commit 52c5788
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/multiprocessing_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
An undecorated example of a script that allocates memory in multiprocessing
workers to demonstrate the use of memory_profiler with multiple processes.
Run this script with mprof run -M python multiprocessing_example.py
Run this script with mprof run -M multiprocessing_example.py
You can then visualize the usage with mprof plot.
"""

Expand Down
10 changes: 9 additions & 1 deletion mprof
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,15 @@ def run_action():

# .. TODO: more than one script as argument ? ..
if args[0].endswith('.py') and not options.nopython:
options.python = True
if options.multiprocess and not args[0].startswith("python"):
# in multiprocessing mode you want to spawn a separate
# python process
args.insert(0, "python")
else:
options.python = True
if options.multiprocess:
# multiprocess can't work in python mode
options.python = False
if options.python:
print("running as a Python program...")
if not args[0].startswith("python"):
Expand Down

0 comments on commit 52c5788

Please sign in to comment.