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

Move signal catching to separate module and refactor #967

Merged
merged 6 commits into from
Jan 25, 2023
Merged

Move signal catching to separate module and refactor #967

merged 6 commits into from
Jan 25, 2023

Conversation

pmrv
Copy link
Contributor

@pmrv pmrv commented Jan 6, 2023

The previous implementation also had the problem that it

  1. never dropped the signal intercept, but installed it on first initialization of any job, even if the job then doesn't actually run,
  2. didn't propagate the signal after it set the job to 'aborted', i.e. trying to interrupt notebooks when no job is running didn't actually interrupt the process
  3. kept re-installing the same handler on every job instantiation. It's not that expensive, but it can cost a few percent of run time, depending on the size of the jobs.

This new implementation only installs the handler during a functions run() method call with a context manager and raises KeyboardInterrupt or calls sys.exit as appropriate.

The previous implementation also had the problem that it
1. never dropped the signal intercept, but installed it on first
   initialization of any job, even if the job then doesn't actually run,
2. didn't propagate the signal after it set the job to 'aborted', i.e.
   trying to interrupt notebooks when no job is running didn't actually
   interrupt the process
3. kept re-installing the same handler on every job instantiation.  It's
   not that expensive, but it can cost a few percent of run time,
   depending on the size of the jobs.

This new implementation only installs the handler during a functions
`run()` method call with a context manager and raises KeyboardInterrupt
or calls sys.exit as appropriate.
@pmrv pmrv marked this pull request as ready for review January 17, 2023 09:57
pyiron_base/state/signal.py Outdated Show resolved Hide resolved
@pmrv pmrv added the format_black reformat the code using the black standard label Jan 17, 2023
@pmrv pmrv added the integration Start the integration tests with pyiron_atomistics/contrib for this PR label Jan 17, 2023
@pmrv
Copy link
Contributor Author

pmrv commented Jan 24, 2023

I've checked now on the cluster that this actually solves the problem of not being able anymore to interrupt notebooks after you've instantiated a job, so I'd like to merge this soon.

@pmrv pmrv merged commit b150200 into main Jan 25, 2023
@delete-merged-branch delete-merged-branch bot deleted the signal branch January 25, 2023 16:09
@jan-janssen jan-janssen mentioned this pull request Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
format_black reformat the code using the black standard integration Start the integration tests with pyiron_atomistics/contrib for this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants