0

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?

User
  • 952
  • 2
  • 21
  • 43

1 Answers1

-1

You have to replace get_open_files() with open_files()

sdevil
  • 1
  • 1