magmax / python-inquirer

A collection of common interactive command line user interfaces, based on Inquirer.js (https://github.com/SBoudrias/Inquirer.js/)
MIT License
1.01k stars 97 forks source link

Heavy CPU usage while waiting for input in PowerShell #113

Closed H0R5E closed 2 years ago

H0R5E commented 3 years ago

Hi,

I noticed that when python-inquirer is waiting for input it is using a lot of CPU (probably a whole CPU thread) while waiting for input. I took these screenshots below:

inquirer_wait

inquirer_cpu

The version I am running is:

inquirer 2.7.0 py_0 conda-forge

It's in a conda environment being run in PowerShell on Windows 10 Pro.

Is this expected behaviour? Is there anyway to make it less hungry?

Many thanks,

Mat

Cube707 commented 2 years ago

this comes from the underlying readchar libary which has a while: True loop in the windows implimentation. This is whats hogging all the CPU. (see https://github.com/magmax/python-readchar/issues/42)

The new v4.0.0 fixes this but is only in pre-release right now. You can however test if it solves this issue if you want.

H0R5E commented 2 years ago

Sure, I'll give it a try.

Cube707 commented 2 years ago

than use this to update your readchar version:

pip install -U --pre readchar
H0R5E commented 2 years ago

low_cpu_usage

Solved! Looking forward to the full release.

Cube707 commented 2 years ago

closed with the latest readchar release