mirror of
https://github.com/1j01/textual-paint.git
synced 2025-01-03 04:16:48 +03:00
Fix terminal state after reloading and exiting
This commit is contained in:
parent
f4075282ce
commit
dfa4212548
10
paint.py
10
paint.py
@ -28,6 +28,16 @@ from localization.i18n import get as _, load_language
|
|||||||
|
|
||||||
def restart_program():
|
def restart_program():
|
||||||
"""Restarts the current program, after file objects and descriptors cleanup"""
|
"""Restarts the current program, after file objects and descriptors cleanup"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
app.exit()
|
||||||
|
# It's meant to eventually call this, but we need it immediately (unless we delay with asyncio perhaps)
|
||||||
|
# Otherwise the terminal will be left in a state where you can't (visibly) type anything
|
||||||
|
# if you exit the app after reloading, since the new process will pick up the old terminal state.
|
||||||
|
app._driver.stop_application_mode()
|
||||||
|
except Exception as e:
|
||||||
|
print("Error stopping application mode. The command line may not work as expected.", e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
p = psutil.Process(os.getpid())
|
p = psutil.Process(os.getpid())
|
||||||
for handler in p.open_files() + p.connections():
|
for handler in p.open_files() + p.connections():
|
||||||
|
Loading…
Reference in New Issue
Block a user