> I'm looking for some information about handling thread safety with Ruby.

In general do not share variables between threads (or at least 
synchronize when you access them), do not interrupt threads by injecting 
interrupts into them (well, you can but...it's dangerous),
add

Thread.abort_on_exception = true # if a thread dies, tell me :)

to your code so that you can debug when exception are thrown but not 
caught...

Also load up all your functions/everything 'single threaded' otherwise 
some of the functions will be 'assigned' to the wrong thread (ugh), then 
be unavailable (classes, modules, too).
I.e. dynamically declared functions are dangerous.

Note also that sometimes if you are reading from TCPSockets the sockets 
get confused and start reading from one another.  To avoid this (I 
think) use Francis Cianfrocca's EventMachine.

That being said it is still fun to program multithreaded stuff in Ruby, 
despite the growing pains and fact that Ruby isn't quite *there* yet.

-Roger

Aaron Smith wrote:
> Hey all,
> 
> I've got an application server I wrote that I need to make sure it's
> thread safe. This application server is used over http requests so it's
> possible multiple people hit it at once. I have some questions that will
> help me determine..
> 
> 1. Does using mongrel / lighttpd / webrick, ensure thread saftey? (my
> application relies on these)
> 2. What kinds of things in the Ruby language should I NOT do that will
> cause thread headaches.. (maybe static variables)?
> 3. What techniques can I use to go about testing thread saftey?
> 
> I'm not asking anything in reference to rails. This would be just
> general Ruby thread safety ideas..
> 
> thanks..

-- 
Posted via http://www.ruby-forum.com/.