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