Cannot timeout on Windows with Runner.run

Open
#867 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
cli

Research direction

Start in invoke/runners.py around the kill method at line 1313 and trace the timeout path used by Runner.run. Reproduce a timed-out command on Windows, then verify that timeout handling terminates it without the reported SIGKILL AttributeError.

Written by the indexing model from the issue text.

Description

Hi!

I am trying to timeout a command run using Runnner.run(..., timeout=3) (invoke >= 1.6.0, python == 3.7.11) but under Windows 10 I get the following error:

Traceback (most recent call last):
  File "~\AppData\Local\Continuum\anaconda3\envs\Project\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "~\AppData\Local\Continuum\anaconda3\envs\Project\lib\threading.py", line 1177, in run
    self.function(*self.args, **self.kwargs)
  File "~\AppData\Local\Continuum\anaconda3\envs\Project\lib\site-packages\invoke\runners.py", line 1313, in kill
    os.kill(pid, signal.SIGKILL)
AttributeError: module 'signal' has no attribute 'SIGKILL'

It seems that SIGKILL is not available in windows: https://docs.python.org/3/library/signal.html#signal.SIGKILL

Here is some more context, potential solutions and caveats: https://stackoverflow.com/a/35792192

Dominant language
Python
Stars
4.8k
Forks
412
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pyinvoke/invoke

All issues in pyinvoke/invoke

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.