Skip to content

Commit

Permalink
Merge 0ad70ea into db3e196
Browse files Browse the repository at this point in the history
  • Loading branch information
amoffatgmi committed Feb 13, 2023
2 parents db3e196 + 0ad70ea commit bd75597
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 14 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
use-select: [0, 1]
lang: [C, en_US.UTF-8]

Expand Down Expand Up @@ -141,6 +141,15 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Get current version
id: get_version
run: echo "::set-output name=version::$(sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml)"

- name: Tag commit
run: |
git tag "$(steps.get_version.outputs.version)" "${{github.ref_name}}""
git push -f origin "$(steps.get_version.outputs.version)"
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Changelog

## 2.0.2 - 2/13/22

- Performance regression when using a generator with `_in` [#650](https://github.com/amoffat/sh/pull/650)

## 2.0.0 - 2/9/22

- Executed commands now return a unicode string by default
- Removed magical module-like execution contexts [#636](https://github.com/amoffat/sh/issues/636)
- Added basic asyncio support via `_async`
- Dropped support for Python < 3.8
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test_one: build_test_image

.PHONY: build_test_image
build_test_image:
docker build -t amoffat/shtest -f tests/Dockerfile --build-arg cache_bust=950 .
docker build -t amoffat/shtest -f tests/Dockerfile --build-arg cache_bust=951 .

# publishes to PYPI
.PHONY: release
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sh"
version = "2.0.1"
version = "2.0.2"
description = "Python subprocess replacement"
authors = ["Andrew Moffat <arwmoffat@gmail.com>"]
readme = "README.rst"
Expand All @@ -22,6 +22,7 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Build Tools",
Expand Down
14 changes: 5 additions & 9 deletions sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2491,16 +2491,12 @@ def is_alive(self):
# so essentially what we're doing is, using this lock, checking if
# we're calling .wait(), and if we are, let .wait() get the exit code
# and handle the status, otherwise let us do it.
acquired = self._wait_lock.acquire(False)
#
# Using a small timeout provides backpressure against code that spams
# calls to .is_alive() which may block the main thread from acquiring
# the lock otherwise.
acquired = self._wait_lock.acquire(timeout=0.00001)
if not acquired:
# this sleep here is a hack. occasionally, is_alive can get called so
# rapidly that it appears to not let the wait lock be acquired in the main
# thread, which is attempting to call wait(). by introducing a tiny sleep
# (ugh), this seems to prevent other threads from equally attempting to
# acquire the lock. TODO find out if this is a general python bug
# if we don't do this, if we're unlucky, some commands may hang for a
# second before terminating, due to their threads spamming is_alive() calls.
time.sleep(0.1)
if self.exit_code is not None:
return False, self.exit_code
return True, self.exit_code
Expand Down
3 changes: 2 additions & 1 deletion tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ RUN apt-get update
RUN apt-get -y install\
python3.8\
python3.9\
python3.10
python3.10\
python3.11

RUN apt-get -y install\
python3.8-distutils\
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{38,39,310}-locale-{c,utf8}-poller-{poll,select},lint
envlist = py{38,39,310,311}-locale-{c,utf8}-poller-{poll,select},lint
isolated_build = True

[testenv]
Expand Down

0 comments on commit bd75597

Please sign in to comment.