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

🐛 FIX: Task.cancel should not set state as EXCEPTED #4792

Merged
merged 8 commits into from
Mar 9, 2021
Merged
3 changes: 2 additions & 1 deletion aiida/engine/processes/calcjobs/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# For further information please visit http://www.aiida.net #
###########################################################################
"""Transport tasks for calculation jobs."""
import asyncio
import functools
import logging
import tempfile
Expand Down Expand Up @@ -406,7 +407,7 @@ async def execute(self) -> plumpy.process_states.State: # type: ignore[override
else:
logger.warning(f'killed CalcJob<{node.pk}> but async future was None')
raise
except (plumpy.process_states.Interruption, plumpy.futures.CancelledError):
except (plumpy.process_states.Interruption, plumpy.futures.CancelledError, asyncio.CancelledError):
ltalirz marked this conversation as resolved.
Show resolved Hide resolved
node.set_process_status(f'Transport task {command} was interrupted')
raise
chrisjsewell marked this conversation as resolved.
Show resolved Hide resolved
else:
Expand Down
4 changes: 4 additions & 0 deletions aiida/engine/transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def do_open():
try:
transport_request.count += 1
yield transport_request.future
except asyncio.CancelledError: # pylint: disable=try-except-raise
ltalirz marked this conversation as resolved.
Show resolved Hide resolved
# note this is only required in python<=3.7,
# where asyncio.CancelledError inherits from Exception
raise
chrisjsewell marked this conversation as resolved.
Show resolved Hide resolved
except Exception:
_LOGGER.error('Exception whilst using transport:\n%s', traceback.format_exc())
raise
Expand Down
5 changes: 5 additions & 0 deletions aiida/manage/external/rmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
###########################################################################
# pylint: disable=cyclic-import
"""Components to communicate tasks to RabbitMQ."""
import asyncio
from collections.abc import Mapping
import logging
import traceback
Expand Down Expand Up @@ -209,6 +210,10 @@ async def _continue(self, communicator, pid, nowait, tag=None):
message = 'the class of the process could not be imported.'
self.handle_continue_exception(node, exception, message)
raise
except asyncio.CancelledError: # pylint: disable=try-except-raise
ltalirz marked this conversation as resolved.
Show resolved Hide resolved
# note this is only required in python<=3.7,
# where asyncio.CancelledError inherits from Exception
raise
except Exception as exception:
message = 'failed to recreate the process instance in order to continue it.'
self.handle_continue_exception(node, exception, message)
Expand Down