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

WIP: Implement option to force kill #288

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

WIP: Implement option to force kill #288

wants to merge 3 commits into from

Conversation

agoscinski
Copy link

@agoscinski agoscinski commented Sep 27, 2024

Do not peform stepping when force_kill command is send. This avoids getting stuck in the kill callback.

This is part of a solution for issue aiidateam/aiida-core#6524 and goes together with the PR in aiidateam/aiida-core#6575

Co-author @khsrali

Do not peform stepping when force_kill command is send.
This avoids getting stuck in the kill callback.
@khsrali khsrali marked this pull request as ready for review October 8, 2024 08:38
@khsrali khsrali requested a review from sphuber October 8, 2024 08:39
Copy link
Collaborator

@sphuber sphuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @agoscinski . Apart from one comment on the implementation, could you please add a unit test for this?

@@ -1131,6 +1131,8 @@ def kill(self, msg: Union[str, None] = None) -> Union[bool, asyncio.Future]:
Kill the process
:param msg: An optional kill message
"""
force_kill = isinstance(msg, str) and '-F' in msg
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of this approach. Why not add a force_kill: bool = False argument to the kill method. From aiida-core you can then pass that in the Communicator.rpc_send method

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @sphuber.
Yes yes, I thought about it, but then we have to modify many functions to pass force_kill hand in hand or even to be compatible with dict.
So far, apparently in plumpy the msg is expected to be a str, if I'm not mistaken.
I tried to keep changes minimal.. although maybe not the best approach

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @sphuber has a good point. If the message content is checked inside the implementation, there is no way for user to know how to call it from looking at the function signature.

It is the function:

    _perform_actions(processes, controller.kill_process, 'kill', 'killing', timeout, wait, msg=message)

who send the rpc message, I think it is even better to change it to, and then can also pass the force_kill

    _perform_actions(processes, functool.partial(controller.kill_process, msg=message), 'kill', 'killing', timeout, wait)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #291, I try to make massage not a global variable so it is able to carry more information. After that it will be straight forward to have force option for the kill method.
Discuss with @khsrali offline, he prefer go with the current change and I'll open an amend PR after #291.

@khsrali Just add unit test for this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of merging this if we agree it is not a good design and we plan on changing it straight after anyway?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think after #291 it is straightforward to pass force option to the kill_process. I leave a port force=False for this purpose. @khsrali can you give it a look?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of merging this if we agree it is not a good design and we plan on changing it straight after anyway?

Well, it would deliver faster to users.

Copy link
Member

@unkcpz unkcpz Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it would deliver faster to users.

I may not agree with this.
Finding workarounds should not be the solution to get features fast deliver to users. The fast deliver is based on developers can quickly reach the agreement. In the case of this PR, the agreement is I'll do refactoring before or an amend fix after, on the message encapsulating part.

@unkcpz unkcpz mentioned this pull request Dec 12, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants