Skip to content

Commit

Permalink
- Prevent potential loop if we loose the session (likely due to a cra…
Browse files Browse the repository at this point in the history
…sh) while watching the status of a cook/instantiation task.
  • Loading branch information
dpernuit committed May 31, 2024
1 parent d79fa46 commit 24a7e9e
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Source/HoudiniEngine/Private/HoudiniEngineScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,24 @@ FHoudiniEngineScheduler::TaskInstantiateAsset(const FHoudiniEngineTask & Task)
break;
}

if (Result == HAPI_RESULT_FAILURE)
{
// There was an error while getting the status - likely we've lost the session.
// Log an error and ensure we break cleanly in that case
HOUDINI_LOG_ERROR(TEXT("Unable to instantiate asset: %s - session failed"), *Task.ActorName);

EHoudiniEngineTaskState TaskStateResult = EHoudiniEngineTaskState::FinishedWithFatalError;

AddResponseMessageTaskInfo(
static_cast<HAPI_Result>(Result),
EHoudiniEngineTaskType::AssetInstantiation,
TaskStateResult,
AssetId, Task,
TEXT("Unable to instantiate the asset: session failed."));

return;
}

static const double NotificationUpdateFrequency = 0.5;
if ((FPlatformTime::Seconds() - LastUpdateTime) >= NotificationUpdateFrequency)
{
Expand Down Expand Up @@ -352,6 +370,25 @@ FHoudiniEngineScheduler::TaskCookAsset(const FHoudiniEngineTask & Task)
break;
}

if (Result == HAPI_RESULT_FAILURE)
{
// There was an error while getting the status - likely we've lost the session.
// Log an error and ensure we break cleanly in that case
HOUDINI_LOG_ERROR(TEXT("Unable to cook asset: %s - session failed"), *Task.ActorName);
GlobalTaskResult = EHoudiniEngineTaskState::FinishedWithFatalError;

// There was an error while cooking.
AddResponseMessageTaskInfo(
HAPI_RESULT_FAILURE,
EHoudiniEngineTaskType::AssetCooking,
EHoudiniEngineTaskState::FinishedWithFatalError,
AssetId,
Task,
TEXT("Unable to cook - session failed"));

return;
}

static const double NotificationUpdateFrequency = 0.5;
if (FPlatformTime::Seconds() - LastUpdateTime >= NotificationUpdateFrequency)
{
Expand Down

0 comments on commit 24a7e9e

Please sign in to comment.