Skip to content

Commit 238e835

Browse files
committed
Remove run(debug=...)
1 parent 8d40216 commit 238e835

File tree

3 files changed

+5
-32
lines changed

3 files changed

+5
-32
lines changed

HISTORY.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ History
1010
(those were deprecated in `#60 <https://github.com/DiamondLightSource/python-procrunner/pull/60>`_)
1111
* Calling the run() function with multiple unnamed arguments is no longer supported
1212
(previously deprecated in `#62 <https://github.com/DiamondLightSource/python-procrunner/pull/62>`_)
13+
* The run() function no longer accepts a 'debug' argument
14+
(previously deprecated in `#63 <https://github.com/DiamondLightSource/python-procrunner/pull/63>`_)
1315

1416
2.3.1 (2021-10-25)
1517
------------------

src/procrunner/__init__.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ def run(
304304
command,
305305
*,
306306
timeout: Optional[float] = None,
307-
debug=None,
308307
stdin: Optional[bytes] = None,
309308
print_stdout: bool = True,
310309
print_stderr: bool = True,
@@ -324,7 +323,6 @@ def run(
324323
325324
:param array command: Command line to be run, specified as array.
326325
:param timeout: Terminate program execution after this many seconds.
327-
:param boolean debug: Enable further debug messages. (deprecated)
328326
:param stdin: Optional bytestring that is passed to command stdin.
329327
:param boolean print_stdout: Pass stdout through to sys.stdout.
330328
:param boolean print_stderr: Pass stderr through to sys.stderr.
@@ -357,10 +355,6 @@ def run(
357355
else:
358356
assert sys.platform != "win32", "stdin argument not supported on Windows"
359357
stdin_pipe = subprocess.PIPE
360-
if debug is not None:
361-
warnings.warn(
362-
"Use of the debug parameter is deprecated", DeprecationWarning, stacklevel=3
363-
)
364358

365359
start_time = timeit.default_timer()
366360
if timeout is not None:
@@ -406,7 +400,6 @@ def run(
406400
stdout = _NonBlockingStreamReader(
407401
p.stdout,
408402
output=print_stdout,
409-
debug=debug,
410403
notify=notifier.close,
411404
callback=callback_stdout,
412405
)
@@ -415,25 +408,19 @@ def run(
415408
stderr = _NonBlockingStreamReader(
416409
p.stderr,
417410
output=print_stderr,
418-
debug=debug,
419411
notify=notifier.close,
420412
callback=callback_stderr,
421413
)
422414
if stdin is not None:
423415
notifyee, notifier = Pipe(False)
424416
thread_pipe_pool.append(notifyee)
425-
_NonBlockingStreamWriter(
426-
p.stdin, data=stdin, debug=debug, notify=notifier.close
427-
)
417+
_NonBlockingStreamWriter(p.stdin, data=stdin, notify=notifier.close)
428418

429419
timeout_encountered = False
430420

431421
while (p.returncode is None) and (
432422
(timeout is None) or (timeit.default_timer() < max_time)
433423
):
434-
if debug and timeout is not None:
435-
logger.debug("still running (T%.2fs)", timeit.default_timer() - max_time)
436-
437424
# wait for some time or until a stream is closed
438425
try:
439426
if thread_pipe_pool:
@@ -450,8 +437,6 @@ def run(
450437
if event:
451438
# One-shot, so remove stream and watch remaining streams
452439
thread_pipe_pool.pop(0)
453-
if debug:
454-
logger.debug("Event received from stream thread")
455440
else:
456441
time.sleep(0.5)
457442
except KeyboardInterrupt:
@@ -465,8 +450,7 @@ def run(
465450
if p.returncode is None:
466451
# timeout condition
467452
timeout_encountered = True
468-
if debug:
469-
logger.debug("timeout (T%.2fs)", timeit.default_timer() - max_time)
453+
logger.debug("timeout (T%.2fs)", timeit.default_timer() - max_time)
470454

471455
# send terminate signal and wait some time for buffers to be read
472456
p.terminate()

tests/test_procrunner.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_run_command_aborts_after_timeout_legacy(
2626

2727
with pytest.raises(RuntimeError):
2828
with pytest.warns(DeprecationWarning, match="timeout"):
29-
procrunner.run(task, timeout=-1, debug=False)
29+
procrunner.run(task, timeout=-1)
3030

3131
assert mock_subprocess.Popen.called
3232
assert mock_process.terminate.called
@@ -95,14 +95,12 @@ def streamreader_processing(*args, **kwargs):
9595
mock.call(
9696
stream_stdout,
9797
output=mock.ANY,
98-
debug=None,
9998
notify=mock.ANY,
10099
callback=mock.sentinel.callback_stdout,
101100
),
102101
mock.call(
103102
stream_stderr,
104103
output=mock.ANY,
105-
debug=None,
106104
notify=mock.ANY,
107105
callback=mock.sentinel.callback_stderr,
108106
),
@@ -128,17 +126,6 @@ def test_default_process_environment_is_parent_environment(mock_subprocess):
128126
assert mock_subprocess.Popen.call_args[1]["env"] == os.environ
129127

130128

131-
@mock.patch("procrunner.subprocess")
132-
def test_using_debug_parameter_raises_warning(mock_subprocess):
133-
mock_subprocess.Popen.side_effect = NotImplementedError() # cut calls short
134-
with pytest.warns(DeprecationWarning, match="debug"):
135-
with pytest.raises(NotImplementedError):
136-
procrunner.run([mock.Mock()], debug=True)
137-
with pytest.warns(DeprecationWarning, match="debug"):
138-
with pytest.raises(NotImplementedError):
139-
procrunner.run([mock.Mock()], debug=False)
140-
141-
142129
@mock.patch("procrunner.subprocess")
143130
def test_pass_custom_environment_to_process(mock_subprocess):
144131
mock_subprocess.Popen.side_effect = NotImplementedError() # cut calls short

0 commit comments

Comments
 (0)