Skip to content

Commit

Permalink
‼️ DEPRECATE: Process.done method (#215)
Browse files Browse the repository at this point in the history
This method is a duplicate of `Process.has_terminated`, and is not used anywhere in plumpy or aiida-core.
  • Loading branch information
chrisjsewell authored Mar 8, 2021
1 parent 99f959b commit 56edeae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
16 changes: 10 additions & 6 deletions plumpy/processes.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# -*- coding: utf-8 -*-
"""The main Process module"""
import abc
import asyncio
import contextlib
import copy
import enum
import functools
import copy
import logging
import time
import sys
import uuid
import asyncio
import time
from types import TracebackType
from typing import (
Any, Awaitable, Callable, cast, Dict, Generator, Hashable, List, Optional, Sequence, Tuple, Type, Union
)
import uuid
import warnings

try:
from aiocontextvars import ContextVar
Expand Down Expand Up @@ -481,9 +482,12 @@ def exception(self) -> Optional[BaseException]:
return None

def done(self) -> bool:
"""Return True if the call was successfully killed or finished running.
.. deprecated:: 0.18.6
Use the `has_terminated` method instead
"""
Return True if the call was successfully killed or finished running.
"""
warnings.warn('method is deprecated, use `has_terminated` instead', DeprecationWarning) # pylint: disable=no-member
return self._state.is_terminal()

# endregion
Expand Down
10 changes: 5 additions & 5 deletions test/test_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def test_execute(self):
proc = utils.DummyProcessWithOutput()
proc.execute()

self.assertTrue(proc.done())
self.assertTrue(proc.has_terminated())
self.assertEqual(proc.state, ProcessState.FINISHED)
self.assertEqual(proc.outputs, {'default': 5})

Expand Down Expand Up @@ -331,7 +331,7 @@ def test_wait_continue(self):
proc.execute()

# Check it's done
self.assertTrue(proc.done())
self.assertTrue(proc.has_terminated())
self.assertEqual(proc.state, ProcessState.FINISHED)

def test_exc_info(self):
Expand All @@ -344,7 +344,7 @@ def test_exc_info(self):
def test_run_done(self):
proc = utils.DummyProcess()
proc.execute()
self.assertTrue(proc.done())
self.assertTrue(proc.has_terminated())

def test_wait_pause_play_resume(self):
"""
Expand All @@ -371,7 +371,7 @@ async def async_test():
await proc.future()

# Check it's done
self.assertTrue(proc.done())
self.assertTrue(proc.has_terminated())
self.assertEqual(proc.state, ProcessState.FINISHED)

loop.create_task(proc.step_until_terminated())
Expand Down Expand Up @@ -412,7 +412,7 @@ async def async_test():
loop.create_task(proc.step_until_terminated())
loop.run_until_complete(async_test())

self.assertTrue(proc.done())
self.assertTrue(proc.has_terminated())
self.assertEqual(proc.state, ProcessState.FINISHED)

def test_kill_in_run(self):
Expand Down
2 changes: 1 addition & 1 deletion test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def __init__(self, proc):

def capture(self):
self._save(self.process)
if not self.process.done():
if not self.process.has_terminated():
try:
self.process.execute()
except Exception:
Expand Down

0 comments on commit 56edeae

Please sign in to comment.