mirror of
https://github.com/1j01/textual-paint.git
synced 2024-11-24 08:44:45 +03:00
Catch ImportError to tweak error message
This commit is contained in:
parent
c88812ff57
commit
40b2b1b1a1
@ -46,13 +46,17 @@ def restart_program() -> None:
|
||||
print("Error stopping file change observer:", e)
|
||||
|
||||
try:
|
||||
import psutil
|
||||
p = psutil.Process(os.getpid())
|
||||
for handler in p.open_files() + p.connections():
|
||||
try:
|
||||
os.close(handler.fd)
|
||||
except Exception as e:
|
||||
print(f"Error closing file descriptor ({handler.fd}):", e)
|
||||
try:
|
||||
import psutil
|
||||
except ImportError:
|
||||
print("psutil module not available; skipping file descriptor cleanup for auto-restart.")
|
||||
else:
|
||||
p = psutil.Process(os.getpid())
|
||||
for handler in p.open_files() + p.connections():
|
||||
try:
|
||||
os.close(handler.fd)
|
||||
except Exception as e:
|
||||
print(f"Error closing file descriptor ({handler.fd}):", e)
|
||||
except Exception as e:
|
||||
print("Error closing file descriptors:", e)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user