Comments (2)
I came up with another solution but stumbled into something like a deadlock. What am I doing wrong @nesquena ?
When I send a SIGTERM
to the worker it tries to stop but the tube.put "-"
somehow causes a deadlock? The output is "hi", "step 1", "step 2" but never reaches the next puts
since it somehow hangs when it puts the job.
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
require "beaneater"
BEANSTALKD_URL = "localhost:11300"
CONTROL_TUBE_NAME = "control-#{1}"
DEFAULT_TUBE_NAME = "test"
class Worker
def process!
beanstalk = Beaneater.new BEANSTALKD_URL
beanstalk.jobs.register DEFAULT_TUBE_NAME do |job|
10.times do |n|
sleep 1
puts n
end
end
beanstalk.jobs.register CONTROL_TUBE_NAME do |job|
puts "stop"
stop
end
beanstalk.jobs.process!
beanstalk.close
end
def stop!
puts "hi"
beanstalk = Beaneater.new BEANSTALKD_URL
puts "step 1"
tube = beanstalk.tubes[CONTROL_TUBE_NAME]
puts "step 2"
tube.put "-"
puts "step 3"
beanstalk.close
puts "bye"
end
private
def stop
raise Beaneater::AbortProcessingError
end
end
worker = Worker.new
Signal.trap "INT" do
worker.stop!
end
Signal.trap "TERM" do
worker.stop!
end
worker.process!
puts "good night"
from beaneater.
I would still appreciate advice but can under stand that there is no time for that.
from beaneater.
Related Issues (20)
- Initial example in documentation is wrong HOT 1
- Do you provide methods for testing worker? HOT 2
- Is there a "queue is empty" hook? HOT 9
- jobs are not reserved but the tube is being watched HOT 2
- Rails 4.2 Active Job Adapter HOT 2
- Job is nil when burying HOT 1
- Automated processing and signal handling
- Beaneater.new requires one argument HOT 3
- Get Number of Ready Jobs Enqueued into a Tube HOT 1
- Duplicate jobs in the queue
- Process! is not propagating Beaneater::NotConnected exception. HOT 1
- Beaneater::Jobs#process shouldn't rescue StandardError
- Segmentation faults
- # different job_serializer/job_parser function by tube
- ENV['BEANSTALKD_URL'] not working? HOT 1
- ENV for the URL :: not working?
- Using Hash#slice forces ruby 2.5+ HOT 4
- Weighted queues HOT 1
- using colon in one parameter causes a weird replacement by underscores HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from beaneater.