I have a GitHub action that resembles the code below. I have a file that is meant to run forever but get interrupted by a user when needed be. I've tried using timeout
but it does not work, and gives some weird message.
A small caveat to this, is that if the process is timed-out, I want this not to raise an error, so that the action continues and reports success. But if the python script itself fails, I want this to be reported, as running it for a while for debugging is the point of running it within the action.
name: Run file with interrupt then save results
on:
push:
branches:
- master
jobs:
build:
strategy:
matrix:
python-version: [3.7]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies for ex 06
run: |
python -m pip install --upgrade pip
cd /home/runner/work/repo_name/repo_name
pip install -r requirements.txt
- name: Run file with timeout
run: |
cd /home/runner/work/repo_name/repo_name/
echo "hi1"
timeout 5 sleep 10
echo "hi2"
python RunsForever.py
echo "hi3"
- name: Upload results
uses: actions/upload-artifact@v2
with:
name: result
path: /home/runner/work/repo_name/repo_name/output/
How can I have timeout working properly? The current error message is:
Run cd /home/runner/work/repo_name/repo_name/
cd /home/runner/work/repo_name/repo_name/
echo "hi1"
timeout 5 sleep 10
echo "hi2"
python RunsForever.py
echo "hi3"
shell: /bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.7.8/x64
hi1
##[error]Process completed with exit code 124.
I don't understand what could be the issue. I expected the problem to be related to the timeout function hiding output from RunsForever.py
, but actually timeout
itself seems not to work. I've tried installing with apt-get
, also to no avail.
Is there some debugging that could get this running? Is there any other method to kill a process so I effectively interrupt it after a predetermined amount of time?