Console CTRL
This simple package allows you to send CTRL-C event to a target console process WITHOUT causing KeyboardInterrput at the caller side.
The solution is based on posts shared on stackoverflow (see Reference for details).
Usage
Install with pip install console-ctrl
In you code:
import console_ctrl
import subprocess
# Start some command IN A SEPARATE CONSOLE
p = subprocess.Popen(['some_command'], creationflags=subprocess.CREATE_NEW_CONSOLE)
# Do something else
console_ctrl.send_ctrl_c(p.pid)
Note: the target process should be started with creationflags=subprocess.CREATE_NEW_CONSOLE.
Reference
Specially thanks to people shared solutions here:
- https://stackoverflow.com/questions/7085604/sending-c-to-python-subprocess-objects-on-windows
- https://stackoverflow.com/questions/813086/can-i-send-a-ctrl-c-sigint-to-an-application-on-windows
More official docs:
Release files for console-ctrl 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| console-ctrl-0.1.0.tar.gz | 2.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| console_ctrl-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.6 kB
Release files / console-ctrl-0.1.0.tar.gz
| Download URL | console-ctrl-0.1.0.tar.gz |
|---|---|
| Size | 2.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e4a21d6a1148bddd50688dadf1b1d28a337a70fb0f52b5e79f0335eb54ea4cf
|
|
BLAKE2b-256 checksum How to use checksums |
cfe9a660d9f118bfb7c8d5c01dfd5c12336d8cc8d0bd287bb533423bf7df2668
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.23.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5
|
Release files / console_ctrl-0.1.0-py3-none-any.whl
| Download URL | console_ctrl-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60239bbfe7d7145b68f19c16818f06a06137efbdc1f6149634daa8ffc14dd5d4
|
|
BLAKE2b-256 checksum How to use checksums |
512cdb21216ca9e80974cf79d19863e87381035e8ebb6fdb2253d6f47f6ff721
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.23.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5
|