Skip to content

Commit

Permalink
Merge pull request #5 from petereon/high_cpu_usage_fix
Browse files Browse the repository at this point in the history
fix: removing the busy waiting block
  • Loading branch information
petereon authored Sep 28, 2023
2 parents b546177 + 0d95330 commit b9e1925
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 28 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]

env:
POETRY_VERSION: "<1.4.0"
jobs:
build:
if: |
Expand All @@ -27,7 +28,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install poetry poethepoet
python -m pip install "poetry${{ env.POETRY_VERSION }}" poethepoet
poetry install
- name: Test with ward
run: |
Expand Down
55 changes: 40 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "python-yakh"
version = "0.3.1"
version = "0.3.2"
description = "Yet Another Keypress Handler"
authors = ["petereon <[email protected]>"]
license = 'MIT'
Expand All @@ -21,10 +21,10 @@ python = "^3.7.8"


[tool.poetry.group.dev.dependencies]
ward = "^0.67.0b0"
ward-coverage = "^0.3.0"
black = "^22.10.0"
pylint = "^2.15.6"
ward = "*"
ward-coverage = "*"
black = "*"
pylint = "*"

[build-system]
requires = ["poetry-core"]
Expand Down
11 changes: 5 additions & 6 deletions yakh/_yakh.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import select
import sys
from typing import List
from yakh.key._key import Key
Expand Down Expand Up @@ -36,14 +37,12 @@ def __get_key() -> str:
tty.setraw(fd_input)
ch_str = ""
try:
select.select([sys.stdin], [], [], None)
while True:
if ch_str != "":
ch_stri = sys.stdin.read(1)
if ch_stri == "":
break
while True:
ch_stri = sys.stdin.read(1)
if ch_stri == "":
break
ch_str += ch_stri
ch_str += ch_stri
except Exception:
pass
finally:
Expand Down

0 comments on commit b9e1925

Please sign in to comment.