[skip ci] test fix
This commit is contained in:
1 parent
fb85ab94f0
commit
f6af555573
1 file changed
+15
-21
@@ -5,29 +5,23 @@ import "pkg:/source/utils/Logging.bs"
|
||||
function ExecuteJob() as void
|
||||
input = JobGetInput()
|
||||
|
||||
if JobIsCancelled()
|
||||
JobCancel()
|
||||
LogInfo("Job cancelled before execution")
|
||||
return
|
||||
end if
|
||||
' Register before reading: a cancel between the read and the registration would reach no observer
|
||||
cancellation = JobGetCancellation()
|
||||
messagePort = CreateObject("roMessagePort")
|
||||
CancellationUtils.ObserveCancellationScoped(cancellation, messagePort)
|
||||
|
||||
cancelled = CancellationUtils.IsCancelled(cancellation)
|
||||
sleepTimeMs = ValidInt(input.sleep)
|
||||
if sleepTimeMs > 0
|
||||
callback = JobGetCallbackNode()
|
||||
if callback <> invalid
|
||||
messagePort = CreateObject("roMessagePort")
|
||||
cancellation = CancellationUtils.CreateCancellation(callback, "cancel", true)
|
||||
CancellationUtils.ObserveCancellationScoped(cancellation, messagePort)
|
||||
message = wait(sleepTimeMs, messagePort)
|
||||
CancellationUtils.UnobserveCancellationScoped(cancellation)
|
||||
if CancellationUtils.IsCancellationEvent(cancellation, message)
|
||||
LogInfo("Job cancelled during execution")
|
||||
JobCancel()
|
||||
return
|
||||
end if
|
||||
else
|
||||
sleep(sleepTimeMs)
|
||||
end if
|
||||
if not cancelled and sleepTimeMs > 0
|
||||
message = wait(sleepTimeMs, messagePort)
|
||||
cancelled = CancellationUtils.IsCancellationEvent(cancellation, message)
|
||||
end if
|
||||
CancellationUtils.UnobserveCancellationScoped(cancellation)
|
||||
|
||||
if cancelled
|
||||
LogInfo("Simulated job cancellation for testing purposes")
|
||||
JobCancel()
|
||||
return
|
||||
end if
|
||||
|
||||
if not input.success
|
||||
|
||||
Reference in new issue
Block a user