Skip to content
Browse files

Don't try to manipulate a job we don't own.

  • Loading branch information...
1 parent d49d242 commit 8915c23559f81cb88ed1272d54356dd33eb62268 Keith Rarick committed
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/beanstalk-client/job.rb
View
13 lib/beanstalk-client/job.rb
@@ -36,16 +36,17 @@ def ybody()
(@ybody ||= [begin YAML.load(body) rescue nil end])[0]
end
- def initialize(conn, id, body)
+ def initialize(conn, id, body, reserved=true)
@conn = conn
@id = id
@body = body
- @deleted = false
+ @reserved = reserved
end
def delete()
- @conn.delete(id) if !@deleted
- @deleted = true
+ return if !@reserved
+ @conn.delete(id)
+ @reserved = false
end
def put_back(pri=self.pri, delay=0, ttr=self.ttr)
@@ -53,11 +54,15 @@ def put_back(pri=self.pri, delay=0, ttr=self.ttr)
end
def release(newpri=pri, delay=0)
+ return if !@reserved
@conn.release(id, newpri, delay)
+ @reserved = false
end
def bury(newpri=pri)
+ return if !@reserved
@conn.bury(id, newpri)
+ @reserved = false
end
def stats()

0 comments on commit 8915c23

Please sign in to comment.
Something went wrong with that request. Please try again.