magmax / python-readchar

Python library to read characters and key strokes
MIT License
143 stars 43 forks source link

Fix for reading input while script is in debug with PyCharm running on MacOS #70

Closed spuliaiev-sfdc closed 1 year ago

spuliaiev-sfdc commented 2 years ago

I notices that when we use this library with enabled debug with PyCharm on MacOS it hangs while requesting the input. Does not matter if the script run in the PyCharm internal terminal, iTerm2 terminal or native MacOS terminal app.

spuliaiev-sfdc commented 2 years ago

Not sure if it need to be extracted into a different file like readchar_mac.py Please advise @magmax

spuliaiev-sfdc commented 2 years ago
============================================= test session starts ==============================================
platform darwin -- Python 3.9.9, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /Users/spuliaiev/work/py/python-readchar, configfile: setup.cfg
plugins: cov-3.0.0
collected 9 items

tests/unit/test_key.py ....                                                                              [ 44%]
tests/unit/test_readkey.py .....                                                                         [100%]

---------- coverage: platform darwin, python 3.9.9-final-0 -----------
Name                           Stmts   Miss  Cover   Missing
------------------------------------------------------------
readchar/__init__.py               3      0   100%
readchar/key.py                   59      0   100%
readchar/readchar.py              38     20    47%   8, 11-17, 30-80
readchar/readchar_linux.py        11      7    36%   11-18
readchar/readchar_windows.py      12     12     0%   5-27
------------------------------------------------------------
TOTAL                            123     39    68%

============================================== 9 passed in 0.07s ===============================================
AndKe commented 2 years ago

hmm ..if this fixes https://github.com/magmax/python-readchar/issues/51 , please merge.

spuliaiev-sfdc commented 2 years ago

@AndKe I have no permissions to do that.

Only those with write access to this repository can merge pull requests.

AndKe commented 2 years ago

I hoped to get the attention of one of those who can.

spuliaiev-sfdc commented 2 years ago

@andreatulimiero @magmax @jhonatan-lopes Could you please take a look?

spuliaiev-sfdc commented 2 years ago

@magmax Would you please take a look?

jhonatan-lopes commented 2 years ago

HI @spuliaiev-sfdc, I'm not a maintainer on this repo. I'm afraid that @magmax is the person you're looking for to review and close the PR.

Cube707 commented 2 years ago

@spuliaiev-sfdc @AndKe

is anyone still interested in this? is the behaviour still the same with the new v4.0.0 that is currently in pre-release?

spuliaiev-sfdc commented 2 years ago

Yes

On Sun, Jul 31, 2022 at 12:12 PM Jan Wille @.***> wrote:

@spuliaiev-sfdc https://github.com/spuliaiev-sfdc @AndKe https://github.com/AndKe

is anyone still interested in this?

— Reply to this email directly, view it on GitHub https://github.com/magmax/python-readchar/pull/70#issuecomment-1200454105, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM3BL5OP3ERL6VNXPCY7LG3VW2QVXANCNFSM5MOEINDQ . You are receiving this because you were mentioned.Message ID: @.***>

-- Sergii Puliaiev Workspace Engineering Team Lead Software Engineer

Cube707 commented 2 years ago

OK, so than I need some information to properly understand this.

First of all, is the behavior still the same with the current code from v4.0.0-dev? (should be same but still..)

Than, using sys.stdin.readline(1) instead or read(1) should mean that readchar no waits until enter is pressed instead of imeadiadly processing the keypress. Is that the case? How is it behaving? Please test with the script found in tests/manual-test.py:

Screenshots would help a lot :+1:

AndKe commented 2 years ago

@Cube707 - This is what I am getting now: Screenshot from 2022-08-01 08-35-06

Cube707 commented 2 years ago

@AndKe I can not reproduce. This works as expected on Linux/Windows:

import readchar

k = readchar.readkey()
print(k)

If you don't find an issue on your end, please open a seperate issue with more details.

Just a thought: the prolem might come from your file beeing named readchar.py. This doesn't pose problems for me, but might explain the circular import.

Cube707 commented 2 years ago

@AndKe I just found the problem. it is indeed the filename readchar.py. Naming the file the same as a imported module will result in a circular import.

Cube707 commented 1 year ago

closing due to inactivity.