diff --git a/src/rpcclient/rpcclient/allocated.py b/src/rpcclient/rpcclient/allocated.py index 18f2096b..80a5c701 100644 --- a/src/rpcclient/rpcclient/allocated.py +++ b/src/rpcclient/rpcclient/allocated.py @@ -13,12 +13,6 @@ def __enter__(self): def __exit__(self, exc_type, exc_val, exc_tb): self.deallocate() - def __del__(self): - try: - self.deallocate() - except Exception: - pass - @abstractmethod def _deallocate(self): pass diff --git a/src/rpcclient/tests/test_allocation_cleanup.py b/src/rpcclient/tests/test_allocation_cleanup.py index e65b0add..36e14229 100644 --- a/src/rpcclient/tests/test_allocation_cleanup.py +++ b/src/rpcclient/tests/test_allocation_cleanup.py @@ -10,29 +10,6 @@ def test_allocate_file_fd_context_manager(client, tmp_path): assert fds_count == len(client.processes.get_by_pid(client.pid).fds) -def test_allocate_file_fd_gc(client, tmp_path): - # make sure when the test starts, all previous Allocated references are freed - gc.collect() - fds_count = len(client.processes.get_by_pid(client.pid).fds) - - # create a new fd with zero references, so it should be free immediately - client.fs.open(tmp_path / 'test', 'w') - - # make sure python's GC had a chance to free the newly created fd - gc.collect() - assert fds_count == len(client.processes.get_by_pid(client.pid).fds) - - -def test_allocate_file_fd_explicit_del(client, tmp_path): - # make sure when the test starts, all previous Allocated references are freed - gc.collect() - fds_count = len(client.processes.get_by_pid(client.pid).fds) - fd = client.fs.open(tmp_path / 'test', 'w') - assert fds_count + 1 == len(client.processes.get_by_pid(client.pid).fds) - del fd - assert fds_count == len(client.processes.get_by_pid(client.pid).fds) - - def test_allocate_file_fd_explicit_deallocate(client, tmp_path): # make sure when the test starts, all previous Allocated references are freed gc.collect()