Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 10 psutil.AccessDenied error #113

Open
tietjen-douglas opened this issue Dec 15, 2020 · 0 comments
Open

Windows 10 psutil.AccessDenied error #113

tietjen-douglas opened this issue Dec 15, 2020 · 0 comments

Comments

@tietjen-douglas
Copy link

tietjen-douglas commented Dec 15, 2020

So when I run python manage.py carrot to try and debug django-carrot on a Windows 10 Pro machine with Django 3.1, I get the following error:

Traceback (most recent call last):
  File "C:\Users\perkl\.virtualenvs\blmh-L0_mRpJz\lib\site-packages\psutil\_common.py", line 446, in wrapper
    ret = self._cache[fun]
AttributeError: _cache

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\perkl\.virtualenvs\blmh-L0_mRpJz\lib\site-packages\psutil\_pswindows.py", line 679, in wrapper
    return fun(self, *args, **kwargs)
  File "C:\Users\perkl\.virtualenvs\blmh-L0_mRpJz\lib\site-packages\psutil\_common.py", line 449, in wrapper
    return fun(self)
  File "C:\Users\perkl\.virtualenvs\blmh-L0_mRpJz\lib\site-packages\psutil\_pswindows.py", line 766, in exe
    exe = cext.proc_exe(self.pid)
PermissionError: [WinError 24] The program issued a command but the command length is incorrect: '(originated from NtQuerySystemInformation)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\perkl\.virtualenvs\blmh-L0_mRpJz\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Users\perkl\.virtualenvs\blmh-L0_mRpJz\lib\site-packages\django\core\management\__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\perkl\.virtualenvs\blmh-L0_mRpJz\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\perkl\.virtualenvs\blmh-L0_mRpJz\lib\site-packages\django\core\management\base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "C:\Users\perkl\.virtualenvs\blmh-L0_mRpJz\lib\site-packages\carrot\management\commands\carrot.py", line 108, in handle
    if 'python' in q.name():
  File "C:\Users\perkl\.virtualenvs\blmh-L0_mRpJz\lib\site-packages\psutil\__init__.py", line 615, in name
    name = self._proc.name()
  File "C:\Users\perkl\.virtualenvs\blmh-L0_mRpJz\lib\site-packages\psutil\_pswindows.py", line 750, in name
    return os.path.basename(self.exe())
  File "C:\Users\perkl\.virtualenvs\blmh-L0_mRpJz\lib\site-packages\psutil\_pswindows.py", line 681, in wrapper
    raise convert_oserror(err, pid=self.pid, name=self._name)
psutil.AccessDenied: psutil.AccessDenied (pid=2340)

If I change the \management\commands\carrot.py to the following, then it solves the problem.

            try:
                if 'python' in q.name():
                    if len(q.cmdline()) > 1 and 'manage.py' in q.cmdline()[1] and 'carrot' in q.cmdline()[2]:
                        if os.name == 'nt':
                            if not q._pid == os.getpid():
                                running_pids.append(q._pid)
                        else:
                            if not q._pid == os.getpgid(0):
                                running_pids.append(q._pid)
            except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
                pass

This was just a quick fix and not sure if it is the best way, but thought I would point it out. My addition was the try except part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant