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

Allow task interruption in groovy scripts #2916

Merged
merged 21 commits into from
Sep 24, 2024
Merged

Conversation

rolnico
Copy link
Member

@rolnico rolnico commented Mar 4, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?
No

What kind of change does this PR introduce?
Feature - same modification as powsybl/powsybl-metrix#129

What is the current behavior?
If a task is interrupted by a user, it's handled differently depending on whether the task contains a groovy script evaluation or not:

  • If it's only a Java task, the interruption is well catched and the task is interrupted
  • If it contains a Groovy script evaluation, the Java thread stops but the groovy evaluation continues, which can cause performance issues if multiple big groovy scripts are running even when they are supposed to be interrupted.

What is the new behavior (if this is a feature change)?

  1. In the groovy CompilerConfiguration, a new ASTTransformationCustomizer on ThreadInterrupt has been added: it automatically adds a check on ThreadInterrupt in every loop (for, while) in the groovy scripts so that they stop if interrupted.
  2. Right before the script evaluation begins, a check is done on the thread interruption in order to not evaluate the script if it has already been interrupted.

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

rolnico added 2 commits March 4, 2024 11:42
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
@rolnico rolnico added the Groovy label Mar 4, 2024
@rolnico rolnico requested a review from geofjamg March 4, 2024 13:11
@rolnico rolnico self-assigned this Mar 4, 2024
@rolnico rolnico requested a review from olperr1 March 5, 2024 07:31
rolnico added 2 commits March 5, 2024 13:20
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
…ion + add tests

Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
@rolnico rolnico marked this pull request as draft March 6, 2024 09:56
rolnico added 4 commits March 6, 2024 15:45
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
# Conflicts:
#	time-series/time-series-dsl/src/main/groovy/com/powsybl/timeseries/dsl/CalculatedTimeSeriesGroovyDslLoader.groovy
rolnico and others added 3 commits March 19, 2024 10:52
…gTask

Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Copy link

olperr1 added 5 commits July 22, 2024 15:57
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Copy link

# Conflicts:
#	computation/src/main/java/com/powsybl/computation/CompletableFutureTask.java
@rolnico rolnico marked this pull request as ready for review September 16, 2024 08:47
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
66.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@olperr1 olperr1 merged commit d7bdbb4 into main Sep 24, 2024
6 of 7 checks passed
@olperr1 olperr1 deleted the nro/groovy_interruption branch September 24, 2024 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants