Blocking ruby threads

I’ve read a lot of bits and pieces in the past but maybe someone can
help me finalize my thoughts here or correct me where I am wrong.

From my understanding ruby threads will not block unless you are
calling out to a C extension which blocks, or in specific off the wall
case like needing to use resolve-replace so dns lookups don’t block.
I understand it to be this way because the select loop that is used to
implement the threads will not do IO reads/writes unless there is data
that is ready.

Am I missing anything here? Are there other edge cases where ruby
threads would block?

Chris

On 24.02.2007 04:41, snacktime wrote:

I’ve read a lot of bits and pieces in the past but maybe someone can
help me finalize my thoughts here or correct me where I am wrong.

From my understanding ruby threads will not block unless you are
calling out to a C extension which blocks, or in specific off the wall
case like needing to use resolve-replace so dns lookups don’t block.

That depends on how DNS lookups are implemented in Ruby. If a standard
library funtion is called then the interpreter might actually block.

I understand it to be this way because the select loop that is used to
implement the threads will not do IO reads/writes unless there is data
that is ready.

Am I missing anything here? Are there other edge cases where ruby
threads would block?

Not exactly an edge case but Ruby threads will block when trying to grab
a mutex or monitor that is hold by another thread.

Kind regards

robert

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs