From: "Darryl L. Pierce" Date: 2012-05-11T21:31:21+09:00 Subject: rb_thread_wait_fd() not waking up (Ruby 1.8.7) I've got a strange situation with an extension on which I'm working. When it is loaded, the extension starts up a long-lived object called CommandRunner on a separate thread. As the extension does its work it push objects into a queue that the CommandRunner then services serially. The objects pushed into that queue each have their own file descriptor (created with pipe()) that they use to communicate back to the extension to say they're done running. The extension, once it has created the object and enqueues it, calls rb_thread_wait_fd() on that file descriptor and, when the object sends the notify, SHOULD wake up and continue executing. This code has worked in past, when I had each of those objects create their own thread of execution to run. But this was a painfully slow process since creating a thread takes time. My goal is to have a single thread (eventually perhaps a few parallel threads) to service these objects. But, for whatever reason, right now everything seems to run (I see the objects doing their work). But the code immediately after rb_thread_wait_fd() never executes. I did a simple test in IRB: >> require 'qpid' => true >> worker = Thread.new do ?> conn = Qpid::Messaging::Connection.new >> conn.open >> session = conn.create_session >> sender = session.create_sender "my-queue;{create:always}" >> receiver = session.create_receiver "my-queue" >> outgoing = Qpid::Messaging::Message.new :content => "This is an outgoing message. #{Time.new}" >> sender.send outgoing >> incoming = receiver.get Qpid::Messaging::Duration::IMMEDIATE >> puts "Incoming message: #{incoming.content}" >> conn.close >> end What I found is that when I took the reference to this separate thread (worker) and forced it to start, it picked up with the line after rb_thread_wait_fd() and worked as expected. Any suggestions on how to debug this problem? -- Darryl L. Pierce Visit the Infobahn Offramp: "Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant