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

AIX 7.2 Failed to iterate through processes using process_iter #1486

Closed
pawelmy opened this issue Apr 11, 2019 · 6 comments
Closed

AIX 7.2 Failed to iterate through processes using process_iter #1486

pawelmy opened this issue Apr 11, 2019 · 6 comments
Assignees

Comments

@pawelmy
Copy link

pawelmy commented Apr 11, 2019

Platform

  • OS: AIX 7.2
  • Python version: 3.7.1
  • psutil version: 5.6.1
  • gcc version: 7.2.0

Bug description
When trying to iterate through processes, psutil crashes with the exception AttributeError: 'function' object has no attribute 'cache_deactivate'. Same issue is visible when running python3 -m psutil.tests (along with other failing tests).

Traceback (most recent call last):
  File "/opt/freeware/lib64/python3.7/site-packages/psutil/__init__.py", line 593, in oneshot
    self._proc.oneshot_enter()
  File "/opt/freeware/lib64/python3.7/site-packages/psutil/_psaix.py", line 369, in oneshot_enter
    self._proc_name_and_args.cache_activate(self)
AttributeError: 'function' object has no attribute 'cache_activate'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/freeware/lib64/python3.7/site-packages/psutil/__init__.py", line 1562, in process_iter
    yield add(pid)
  File "/opt/freeware/lib64/python3.7/site-packages/psutil/__init__.py", line 1539, in add
    proc.info = proc.as_dict(attrs=attrs, ad_value=ad_value)
  File "/opt/freeware/lib64/python3.7/site-packages/psutil/__init__.py", line 627, in as_dict
    with self.oneshot():
  File "/opt/freeware/lib64/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/opt/freeware/lib64/python3.7/site-packages/psutil/__init__.py", line 601, in oneshot
    self._proc.oneshot_exit()
  File "/opt/freeware/lib64/python3.7/site-packages/psutil/_psaix.py", line 374, in oneshot_exit
    self._proc_name_and_args.cache_deactivate(self)
AttributeError: 'function' object has no attribute 'cache_deactivate'

Way to reproduce

import psutil
for p in psutil.process_iter(attrs=["cmdline"]):
    p.info.get("cmdline")

Test results

======================================================================
ERROR: psutil.tests.test_contracts.TestFetchAllProcesses.test_fetch_all
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/freeware/lib64/python3.7/site-packages/psutil/__init__.py", line 593, in oneshot
    self._proc.oneshot_enter()
  File "/opt/freeware/lib64/python3.7/site-packages/psutil/_psaix.py", line 369, in oneshot_enter
    self._proc_name_and_args.cache_activate(self)
AttributeError: 'function' object has no attribute 'cache_activate'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/freeware/lib64/python3.7/site-packages/psutil/tests/test_contracts.py", line 337, in test_fetch_all
    for p, name in self.iter_procs():
  File "/opt/freeware/lib64/python3.7/site-packages/psutil/tests/test_contracts.py", line 316, in iter_procs
    with p.oneshot():
  File "/opt/freeware/lib64/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/opt/freeware/lib64/python3.7/site-packages/psutil/__init__.py", line 601, in oneshot
    self._proc.oneshot_exit()
  File "/opt/freeware/lib64/python3.7/site-packages/psutil/_psaix.py", line 374, in oneshot_exit
    self._proc_name_and_args.cache_deactivate(self)
AttributeError: 'function' object has no attribute 'cache_deactivate'
@giampaolo
Copy link
Owner

Weird but I can't test it. Can you paste the full test output?

@giampaolo giampaolo added the aix label Apr 11, 2019
@pawelmy
Copy link
Author

pawelmy commented Apr 12, 2019

Here's the full log from python3 -m psutil.tests
psutil-test.log

@pawelmy
Copy link
Author

pawelmy commented Apr 15, 2019

@giampaolo If you have any ideas on a potential fix let me know and I can test it in my environment.

@wiggin15
Copy link
Collaborator

I can reproduce this. Happens because of we added the wrap_exceptions decorator on top of memoize_when_activated, and it probably stripped the extra cache methods (attributes) of the wrapped functions. Apparently we are missing functools.wraps in wrap_exceptions on some of the platforms.

@giampaolo
Copy link
Owner

Good catch (also _pssunos.py). Adding functools.wraps fixes it, right?

@wiggin15
Copy link
Collaborator

Just tested. Yes.

nlevitt added a commit to nlevitt/psutil that referenced this issue May 6, 2019
* origin/master:
  Fix giampaolo#1276: [AIX] use getargs to get process cmdline (giampaolo#1500) (patch by @wiggin15)
  Fix Process.ionice example using wrong keyword arg (giampaolo#1504)
  fix history syntax
  remove catching IOError; let the test fail and adjust it later
  Fix cpu freq (giampaolo#1496)
  pre release
  fix giampaolo#1493: [Linux] cpu_freq(): handle the case where /sys/devices/system/cpu/cpufreq/ exists but is empty.
  Revert "Fix cpu_freq (giampaolo#1493)" (giampaolo#1495)
  Fix cpu_freq (giampaolo#1493)
  Update cpu_freq to return 0 for max/min if not available (giampaolo#1487)
  give CREDITS to @agnewee for giampaolo#1491
  SunOS / net_if_addrs(): free() ifap struct on error (giampaolo#1491)
  fix giampaolo#1486: add wraps() decorator around wrap_exceptions
  refactor/move some utilities into _common.py
  update doc
  update HISTORY
  Implement getloadavg on Windows. Fixes giampaolo#604 and giampaolo#1484 (giampaolo#1485) (patch by Ammar Askar)
  give credits to @amanusk for giampaolo#1472
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants