Skip to content

Commit ecf7de2

Browse files
committed
fix(task): return early if task state set
1 parent 395332d commit ecf7de2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/placeos-driver/task.cr

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class PlaceOS::Driver::Task
121121
#
122122
# The result should support conversion to JSON otherwise the remote will only receive `nil`
123123
def success(result = nil, @code = 200)
124+
return self unless @state.unknown?
124125
@state = :success
125126
@wait = false
126127

@@ -168,9 +169,11 @@ class PlaceOS::Driver::Task
168169

169170
# call when the task has failed and we don't want to retry
170171
def abort(reason = nil, @code = 500)
172+
return self unless @state.unknown?
173+
@state = :abort
174+
171175
stop_timers
172176
@wait = false
173-
@state = :abort
174177
@payload = reason.to_s if reason
175178
@channel.close
176179
@complete.send true

0 commit comments

Comments
 (0)