Skip to content

Commit

Permalink
fix defer
Browse files Browse the repository at this point in the history
  • Loading branch information
likawind committed Feb 1, 2023
1 parent 3c0bcc1 commit 2eef267
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
31 changes: 17 additions & 14 deletions src/golang/lib/engine/aq_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ func onFinishExecution(
integrationRepo repos.Integration,
DB database.Database,
) {
// Wait a little bit for all active operators to finish before exiting on failure.
waitForInProgressOperators(ctx, inProgressOps, pollInterval, cleanupTimeout)
if curErr != nil && notificationContent == nil {
notificationContent = &notificationContentStruct{
Expand All @@ -849,6 +850,7 @@ func onFinishExecution(
}
}

// Send notifications
if notificationContent != nil && execMode == operator.Publish {
err := sendNotifications(
ctx,
Expand Down Expand Up @@ -892,20 +894,21 @@ func (eng *aqEngine) execute(
return errors.Newf("No initial operators to schedule.")
}

// Wait a little bit for all active operators to finish before exiting on failure.
defer onFinishExecution(
ctx,
inProgressOps,
timeConfig.OperatorPollInterval,
timeConfig.CleanupTimeout,
err,
notificationContent,
workflowDag,
opExecMode,
vaultObject,
eng.IntegrationRepo,
eng.Database,
)
defer func() {
onFinishExecution(
ctx,
inProgressOps,
timeConfig.OperatorPollInterval,
timeConfig.CleanupTimeout,
err,
notificationContent,
workflowDag,
opExecMode,
vaultObject,
eng.IntegrationRepo,
eng.Database,
)
}()

start := time.Now()

Expand Down
29 changes: 15 additions & 14 deletions src/golang/lib/engine/databricks_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,21 @@ func ExecuteDatabricks(
return errors.Newf("No initial operators to schedule.")
}

// Wait a little bit for all active operators to finish before exiting on failure.
defer onFinishExecution(
ctx,
inProgressOps,
timeConfig.OperatorPollInterval,
timeConfig.CleanupTimeout,
err,
notificationContent,
dag,
opExecMode,
vaultObject,
integrationRepo,
DB,
)
defer func() {
onFinishExecution(
ctx,
inProgressOps,
timeConfig.OperatorPollInterval,
timeConfig.CleanupTimeout,
err,
notificationContent,
dag,
opExecMode,
vaultObject,
integrationRepo,
DB,
)
}()

start := time.Now()
var operatorError error
Expand Down

0 comments on commit 2eef267

Please sign in to comment.