Skip to content

Instantly share code, notes, and snippets.

@nicoddemus
Created December 6, 2016 20:45
Show Gist options
  • Save nicoddemus/21417f07b42629a474c9b90d996fdaab to your computer and use it in GitHub Desktop.
Save nicoddemus/21417f07b42629a474c9b90d996fdaab to your computer and use it in GitHub Desktop.
try:
os.remove(filename)
except PermissionError as e:
print('THIS PID', os.getpid())
import psutil
for proc in psutil.process_iter():
try:
files = proc.open_files()
except psutil.AccessDenied:
continue
if files:
print(proc.pid, proc.name)
for filename in files:
print(" -", filename.path)
assert 0, str(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment