Running the code below associated with the answer of @s3ni0r here using python 3.8
import os
import sys
import psutil
import logging
def restart_program():
"""Restarts the current program, with file objects and descriptors
cleanup
"""
try:
p = psutil.Process(os.getpid())
for handler in p.get_open_files() + p.connections():
os.close(handler.fd)
except Exception as e:
logging.error(e)
python = sys.executable
os.execl(python, python, *sys.argv)
runs into
ERROR:root:'Process' object has no attribute 'get_open_files'
Does anyone know what should be updated?