Forum: Ruby blocking ruby threads

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
snacktime (Guest)
on 2007-02-24 05:41
(Received via mailing list)
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
Robert K. (Guest)
on 2007-02-24 12:01
(Received via mailing list)
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 topic is locked and can not be replied to.