Skip to content

Commit 7dc8ff4

Browse files
Add Runner.is_worker() helper method
1 parent d2cc803 commit 7dc8ff4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pyperf/_runner.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ def __init__(self, values=None, processes=None,
7878
show_name=True,
7979
program_args=None, add_cmdline_args=None,
8080
_argparser=None, warmups=1):
81+
def is_worker(self) -> bool:
82+
"""Return True if the current process is a worker process."""
83+
if self.args is None:
84+
return False
85+
return bool(self.args.worker)
8186

8287
# Watchdog: ensure that only once instance of Runner (or a Runner
8388
# subclass) is created per process to prevent bad surprises

0 commit comments

Comments
 (0)