Update reloader.py

This commit is contained in:
_run 2022-12-13 18:44:41 +04:00 committed by GitHub
parent 6373af78f3
commit 45fe2ea319
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -18,8 +18,14 @@ def restart_file():
p = psutil.Process(os.getpid())
for handler in p.open_files() + p.connections():
os.close(handler.fd)
except OSError:
pass
except Exception as e:
logger.error(e)
python = sys.executable
os.execl(python, python, *sys.argv)
if os.name == 'nt':
os.execv(sys.executable, ['python'] + sys.argv)
else:
os.execl(python, python, *sys.argv)