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

Improves Scheduler ctrl+c handling #105

Merged
merged 5 commits into from
Nov 9, 2021

Conversation

joaomcteixeira
Copy link
Member

@joaomcteixeira joaomcteixeira commented Oct 31, 2021

Closes #96

Now has a controlled exit message for when the user presses ctrl+c while cns is running. CNS error messages due to ctrl+c will be ignored and not printed. CNS error messages should be raised as CNSRunningError, as before.

example:

[2021-10-31 12:19:21,450] haddock.libs.libparallel:L64 INFO - Scheduler configurated for 2 cpu cores.
[2021-10-31 12:19:21,450] haddock.libs.libparallel:L17 INFO - Worker ready with 1 tasks
[2021-10-31 12:19:21,450] haddock.libs.libparallel:L17 INFO - Worker ready with 1 tasks
[2021-10-31 12:19:21,450] haddock.libs.libparallel:L55 INFO - 2 tasks ready.
^C[2021-10-31 12:19:21,819] haddock.libs.libparallel:L80 INFO - You have halted subprocess execution by hitting Ctrl+c
[2021-10-31 12:19:21,819] haddock.libs.libparallel:L89 INFO - The workers terminated in a controlled way
# haddock3 exists here

@joaomcteixeira joaomcteixeira added the enhancement Enhancing an existing feature of adding a new one label Oct 31, 2021
@joaomcteixeira joaomcteixeira self-assigned this Oct 31, 2021
@joaomcteixeira joaomcteixeira added this to In progress in Enhancements via automation Oct 31, 2021
@amjjbonvin
Copy link
Member

amjjbonvin commented Oct 31, 2021 via email

@joaomcteixeira
Copy link
Member Author

Sorry, the message does not say CNS any more, I forgot to update the description after the last commit (ad156e8). However, you are right and the new implementation does not affect lightdock because it does not use the Scheduler. I will expand this implementation to third party libraries as well.

@joaomcteixeira
Copy link
Member Author

joaomcteixeira commented Nov 3, 2021

Hi @amjjbonvin the last commit should address your question. I rose the catcher to Step so now it catches KeyboardInterrupt on both native and third-party libraries, for example:

Note the ^C printed character.

in RIGIDBODY

[2021-11-03 12:38:58,349] haddock.libs.libparallel:L64 INFO - Scheduler configurated for 2 cpu cores.
[2021-11-03 12:38:58,349] haddock.libs.libparallel:L17 INFO - Worker ready with 1 tasks
[2021-11-03 12:38:58,349] haddock.libs.libparallel:L17 INFO - Worker ready with 1 tasks
[2021-11-03 12:38:58,349] haddock.libs.libparallel:L55 INFO - 2 tasks ready.
^C[2021-11-03 12:38:58,944] haddock.libs.libparallel:L88 INFO - The workers terminated in a controlled way
[2021-11-03 12:38:58,945] haddock.libs.libworkflow:L87 INFO - You have halted subprocess execution by hitting Ctrl+c
[2021-11-03 12:38:58,945] haddock.libs.libworkflow:L88 INFO - Exiting...

in LightDock

^CProcess Tentacle-1:
[lightdock] INFO: Caught interrupt...
Process Tentacle-2:
Process Tentacle-3:
[kraken] WARNING: Kraken sunk to the bottom of the ocean
[lightdock] INFO: bye.
[2021-11-03 12:52:45,847] haddock.libs.libworkflow:L87 INFO - You have halted subprocess execution by hitting Ctrl+c
[2021-11-03 12:52:45,847] haddock.libs.libworkflow:L88 INFO - Exiting...

Tests as not yet extensive for this PR as they are not critical. I will work on non-critical tests at later dedicated PRs.

@rvhonorato
Copy link
Member

Does this mean that every method needs to have a way to catch ctrl-c?

@joaomcteixeira
Copy link
Member Author

No, the ctrl-c catch is defined in the Step and in the Worker.

@joaomcteixeira
Copy link
Member Author

Conflicts solved, you can review.

Copy link
Member

@rvhonorato rvhonorato left a comment

Choose a reason for hiding this comment

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

Code looks good!

@joaomcteixeira joaomcteixeira merged commit b7a9d8b into haddocking:main Nov 9, 2021
Enhancements automation moved this from In progress to Done Nov 9, 2021
@joaomcteixeira joaomcteixeira deleted the CNS_ctrl-c branch November 9, 2021 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancing an existing feature of adding a new one
Projects
Enhancements
  
Done
Development

Successfully merging this pull request may close these issues.

Better control of Ctrl+c breaks with CNS
3 participants