Skip to content

Commit

Permalink
Add task pending event
Browse files Browse the repository at this point in the history
  • Loading branch information
pditommaso committed Aug 6, 2019
1 parent 5e19f72 commit d2d6669
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions modules/nextflow/src/main/groovy/nextflow/Session.groovy
Expand Up @@ -944,6 +944,18 @@ class Session implements ISession {
}
}

void notifyTaskPending( TaskHandler handler ) {
for( int i=0; i<observers.size(); i++ ) {
final observer = observers.get(i)
try {
observer.onProcessPending(handler, handler.getTraceRecord())
}
catch( Exception e ) {
log.debug(e.getMessage(), e)
}
}
}

/**
* Notifies that a task has been submitted
*/
Expand Down
Expand Up @@ -225,6 +225,7 @@ class TaskPollingMonitor implements TaskMonitor {
try{
pendingQueue << handler
taskAvail.signal() // signal that a new task is available for execution
session.notifyTaskPending(handler)
log.trace "Scheduled task > $handler"
}
finally {
Expand Down
Expand Up @@ -48,6 +48,16 @@ trait TraceObserver {
*/
void onProcessTerminate( TaskProcessor process ){}

/**
* This method when a new task is created and submitted in the nextflow
* internal queue of pending task to be scheduled to the underlying
* execution backend
*
* @param handler
* @param trace
*/
void onProcessPending(TaskHandler handler, TraceRecord trace){}

/**
* This method is invoked before a process run is going to be submitted
*
Expand Down

0 comments on commit d2d6669

Please sign in to comment.