Skip to content

Commit

Permalink
Fix the default for async finalizer (#5013)
Browse files Browse the repository at this point in the history

Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso authored May 22, 2024
1 parent e2e6081 commit f5fba70
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class TaskPollingMonitor implements TaskMonitor {
@Lazy
private ExecutorService finalizerPool = { session.taskFinalizerExecutorService() }()

private boolean enableAsyncFinalizer = SysEnv.get('NXF_ENABLE_ASYNC_FINALIZER','false') as boolean
private boolean enableAsyncFinalizer = SysEnv.getBool('NXF_ENABLE_ASYNC_FINALIZER',true)

/**
* Create the task polling monitor with the provided named parameters object.
Expand Down
5 changes: 5 additions & 0 deletions modules/nf-commons/src/main/nextflow/SysEnv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class SysEnv {
return holder.containsKey(name) ? holder.get(name) : defValue
}

static boolean getBool(String name, boolean defValue) {
final result = get(name,String.valueOf(defValue))
return Boolean.parseBoolean(result)
}

static void push(Map<String,String> env) {
history.push(holder.getTarget())
holder.setTarget(env)
Expand Down
21 changes: 21 additions & 0 deletions modules/nf-commons/src/test/nextflow/SysEnvTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package nextflow

import spock.lang.Specification
import spock.lang.Unroll

/**
*
Expand Down Expand Up @@ -54,4 +55,24 @@ class SysEnvTest extends Specification {
SysEnv.get('HOME') == System.getenv('HOME')

}

@Unroll
def 'should get bool value' () {
given:
SysEnv.push(STATE)

expect:
SysEnv.getBool('FOO', DEF) == EXPECTED

where:
STATE | DEF | EXPECTED
[:] | false | false
[FOO:'false'] | false | false
[FOO:'true'] | false | true
and:
[:] | true | true
[FOO:'false'] | false | false
[FOO:'true'] | true | true

}
}

0 comments on commit f5fba70

Please sign in to comment.