Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Jun 22 20:08
    chrisseaton commented #605
  • Jun 22 16:48
    brauliobo commented #605
  • Jun 22 16:47
    brauliobo commented #605
  • May 04 21:20
    chrisseaton reopened #808
  • May 04 21:20
    chrisseaton commented #808
  • May 04 03:34
    blizzart commented #808
  • Apr 29 16:41
    cwli24 closed #957
  • Apr 29 16:41
    cwli24 commented #957
  • Apr 29 16:01
    cwli24 commented #957
  • Apr 29 15:45
    cwli24 edited #957
  • Apr 29 14:50
    cwli24 edited #957
  • Apr 29 14:48
    cwli24 opened #957
  • Apr 11 04:22
    mhenrixon commented #926
  • Apr 10 20:19
    chrisseaton commented #926
  • Apr 10 19:21
    mhenrixon commented #926
  • Apr 10 08:46
    eregon commented #926
  • Apr 09 13:11
    mhenrixon commented #926
  • Apr 06 15:05
    c960657 commented #956
  • Apr 06 15:00
    jdantonio commented #956
  • Apr 06 14:38
    c960657 commented #956
Charles Oliver Nutter
yah unfortunate this has such a complex build process but I think your best option right now is to just download a JRuby tarball and put it in the env
then things should build ok
the Rakefile for the project explicitly tries to build the jar
it also uses a separate library "ruby-compiler" to do that build, which wants a full JRuby install available
patching those to work will require a cascade of changes
Sorry for the ignorance, but does gem build invoke rake?
Charles Oliver Nutter
but if you download a JRuby tarball and unpack it and point JRUBY_HOME at it, I think this all will work
ah I see what you're sayting
no it does not...that might be an ok workaround for you if you're ok with the CRuby extension building when you install the gem
I thought you might be wanting to precompile everything
gem build will just literally include the files listed in the gemspec
if that resulting gem works for you I think you're ok
Thanks a million for your help
I really appreciate you taking the time to explain things
Charles Oliver Nutter
sure, hopefully this works ok for you
Farid Zakaria
Hey @headius ;
I have a question -- are you aware of any JRuby bugs on previous versions where after a Thread#kill was issued; the thread hung around?
I am investigating an issue where we are starting a watchdog thread (heartbeat); and eventually calling Thread#kill on it.
The thread seems to be alive afterwards though.
Farid Zakaria
Olle Jonsson
@pitr-ch I'm attempting to configure Rubinius for CI, so that the project does not have all this Rubinius-supporting code for nothing.

Using https://travis-ci.org/ruby-concurrency/concurrent-ruby/jobs/659471195

osx, Xcode: xcode8 Ruby: rbx-3.107

Olle Jonsson
I figured it out, had to use Trusty dist, then it actually finds it!
Denis Semenenko

Hey. I have a Javascript Promise/A+ background. Trying to understand the API reference, cause it's hard to find any examples for the library usage in the Net.

The question is how to create a pending Promise?

I use multiple constructor functions like: Concurrent::Promises.future and Concurrent::Promises.zip_futures (aka Promise.all) and both start to invoke resolver immediately.
I want to be able to resolve explicitly with the wait/result/value method.
Instead, now I need to add an unneeded condition like this:
result.wait unless result.fulfilled?


Ben Sheldon (he/him)

@Hyperc0der_twitter here's a GitHub search that has plenty of code examples:


I do though think most usages are executing the promise and resolving.

Aditya C S
Hi All
How do we close Thread which is started by Channel.go
If we have code like below
Concurrent::Channel.go do
  loop do
    Concurrent::Channel.select do |s|
        s.take(somechannel) {
          #do something
        s.take(otherchannel) {
          # dosomething
Thread started by Channel.go is always active. Is there any way we can close this thread explicitly?
closing the channels will stop the loop and selection. However, the Channel.go thread will always remain active
Ben Sheldon (he/him)
@adityacs hi! I don't have much experience with channels, but I have two questions:
  1. Have you verified the loop is broken? For example, by puts-ing a message after the loop-end. I don't see an block-breaking return or throw in what you posted.
  2. Concurrent ruby typically runs things on a global thread pool that will manage, reuse and recycle threads on its own. So if you're confident that the thread isn't doing any work, it shouldn't need to be actively killed.
Aditya C S
@bensheldon_twitter Yeah, the loop is broken and thread is not doing any work
Tomek Wałkuski
Hi all! Do you recommend any resources on testing Async and TimerTask enabled classes?
Ben Sheldon (he/him)
@tomekw hi! I didn't find sources in testing, but I went towards integration testing. You could probably extract and test the task method themselves. Here's what I did with RSpec if your curious:

Hi all. I have a problem when converting a js function to ruby, using concurrent-ruby gem.

JS code:

async function test_js(redis) {
  const arrPromises = [];


  await Promise.all(arrPromisses);
  logger.info('remove success');

Ruby code:

promises = []

promises << Concurrent::Promise.new do
promises << Concurrent::Promise.new do

promises.each { |j| j.execute }
  then{|result| puts "remove success" }.
  rescue { |reason| puts reason }.execute

I'm quite confused cause Promise.all(arrPromisses) will execute all promisses in this array at the same time, while promises.each { |j| j.execute } delay a litle bit cause they're in loop.
Is there any better way to convert this js function to ruby code?
Thank you (bow)

Mikael Henriksson

I think that first of all you should prefer the Concurrent::Promises (plural) which seems to do the trick for me.

Let’s see if I can find the code...

@tuantv-0547 I did something like this:

def tasks
  files.map do |original_file|
    Concurrent::Promises.future(original_file) { |file| process_file(file) }.rescue do |exception|

def process_file(file)
  ProcessFile.perform(file: file, dir: dir, declaration_uuid: declaration_uuid)
If I am not mistaken this was kind of the whole point about the Promises api to provide better support for the exact thing you are trying to achieve.
Shawn Anderson
Not sure if this is the right place, but can anyone here describe the roadmap of getting this PR merged: ruby-concurrency/concurrent-ruby#856 ?
It's blocking my use of concurrent-ruby in production now (which makes me sad, because concurrent-ruby is awesome!)
Aditya C S
Noticed a strange behaviour. Channel.select doesn't block on channels and when used within loop it consumes full cpu(single core). Created an issue here ruby-concurrency/concurrent-ruby#883.

Hi guys!
I have read the doc about high level abstracts but I am still unable to find out what to use.
Here is my use case:

I have a sidekiq worker class that run for quite long sometimes.
Jobs and their states are persisted in database records.

class Worker
  include Sidekiq::Worker

  def perform



However since sometimes worker processes are restarted due to code release
The job record state is "stuck" on "started"
My idea is to raise error when sidekiq is detected to be "quiet" and rescue that error to update job status.
Can someone provide some advice/direction on the implementaion?

Tried Concurrent::TimerTask but my sample code would not raise error on main thread
timer_task = Concurrent::TimerTask.new(execution_interval: 1, run_now: false) do |task|
  task.execution_interval.to_i.times{ STDOUT.puts 'Boom! ' }
  STDOUT.print "\n"
  task.execution_interval += 1
  if task.execution_interval > 2
    STDOUT.puts 'Stopping...'
    raise RuntimeError.new("bye")
timer_task.with_observer do |_time, _result, ex|
  STDOUT.puts "in observer"
  next unless ex
  STDOUT.puts ex
  if ex.is_a?(RuntimeError)
    STDOUT.puts "ex is Interrupt"
    raise ex
main_thread = ::Thread.current
timer_task = Concurrent::TimerTask.new(execution_interval: 1, run_now: false) do |task|
  $sidekiq_is_quiet.tap do |quiet|
    task.shutdown if quiet
timer_task.with_observer do |_time, quiet|
  puts "with_observer >>"
  next unless quiet

  puts "raising"
  main_thread.raise "Sidekiq is quiet!"
Just got this and it seems working
Slamet Kristanto (Kris)
Hi there!
I'm wondering if it's possible to pass an additional lock/mutex to something such as Concurrent::Array in order to more easily perform atomic tasks on multiple collections at once
such as where I need to remove something from one and add it to another, atomically