diff --git a/HISTORY.rst b/HISTORY.rst index 605a56481..1634e4339 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,7 +12,6 @@ XXXX-XX-XX directory for additional data. (patch by Javad Karabi) - 1652_: [Windows] dropped support for Windows XP and Windows Server 2003. Minimum supported Windows version now is Windows Vista. -- 1667_: added process_iter(new_only=True) parameter. - 1671_: [FreeBSD] add CI testing/service for FreeBSD (Cirrus CI). - 1677_: [Windows] process exe() will succeed for all process PIDs (instead of raising AccessDenied). diff --git a/docs/index.rst b/docs/index.rst index 677199922..c5de1802c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -857,7 +857,7 @@ Functions .. versionchanged:: 5.6.0 PIDs are returned in sorted order -.. function:: process_iter(attrs=None, ad_value=None, new_only=False) +.. function:: process_iter(attrs=None, ad_value=None) Return an iterator yielding a :class:`Process` class instance for all running processes on the local machine. @@ -873,8 +873,6 @@ Functions ``info`` attribute attached to the returned :class:`Process` instances. If *attrs* is an empty list it will retrieve all process info (slow). - If *new_only* is true this function will take into consideration only - new PIDs which appeared since the last time it was was called. Sorting order in which processes are returned is based on their PID. Example:: @@ -898,18 +896,9 @@ Functions 3: {'name': 'ksoftirqd/0', 'username': 'root'}, ...} - Get only new processes since last call:: - - >>> for proc in psutil.process_iter(['pid', 'name'], new_only=True): - ... print(proc.info) - ... - .. versionchanged:: 5.3.0 added "attrs" and "ad_value" parameters. - .. versionchanged:: - 5.7.0 added "new_only" parameter. - .. function:: pid_exists(pid) Check whether the given PID exists in the current process list. This is diff --git a/psutil/__init__.py b/psutil/__init__.py index a58b452cb..2f4e147fb 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -1407,7 +1407,7 @@ def pid_exists(pid): _lock = threading.Lock() -def process_iter(attrs=None, ad_value=None, new_only=False): +def process_iter(attrs=None, ad_value=None): """Return a generator yielding a Process instance for all running processes. @@ -1428,8 +1428,6 @@ def process_iter(attrs=None, ad_value=None, new_only=False): If *attrs* is an empty list it will retrieve all process info (slow). - If *new_only* is true this function will take into consideration - only new PIDs which appeared since the last time it was called. """ def add(pid): proc = Process(pid) @@ -1452,8 +1450,6 @@ def remove(pid): with _lock: ls = list(dict.fromkeys(new_pids).items()) - if not new_only: - ls += list(_pmap.items()) ls.sort() for pid, proc in ls: diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py index c32e8a737..3834209fc 100755 --- a/psutil/tests/test_system.py +++ b/psutil/tests/test_system.py @@ -105,22 +105,6 @@ def test_prcess_iter_w_attrs(self): self.assertGreaterEqual(p.info['pid'], 0) assert m.called - def test_process_iter_new_only(self): - ls1 = list(psutil.process_iter(attrs=['pid'])) - ls2 = list(psutil.process_iter(attrs=['pid'], new_only=True)) - self.assertGreater(len(ls1), len(ls2)) - # assume no more than 3 new processes were created in the meantime - self.assertIn(len(ls2), [0, 1, 2, 3, 4, 5]) - - sproc = get_test_subprocess() - ls = list(psutil.process_iter(attrs=['pid'], new_only=True)) - self.assertIn(len(ls2), [0, 1, 2, 3, 4, 5]) - for p in ls: - if p.pid == sproc.pid: - break - else: - self.fail("subprocess not found") - @unittest.skipIf(PYPY and WINDOWS, "get_test_subprocess() unreliable on PYPY + WINDOWS") def test_wait_procs(self):