El Lunes, 28 de Diciembre de 2009, Iñaki Baz Castillo escribió:
> El Lunes, 28 de Diciembre de 2009, Iñaki Baz Castillo escribió:
> > Hi, in my app I'm trying to test if a DB connection works during startup.
> > However I've realized that, in case the DB host doesn't reply, the emthod
> > "test_connection" gets blocked forever, and the worst: it blocks the
> > entire Ruby process so threading is not possible:
>
> It's even worse: Sequel blocks the entire Ruby process when it cannot
> connect to a database:
It's a problem of the MySQL driver (also in mysqlplus):
-------------------
#!/usr/local/bin/ruby1.9
require "mysql" # Tested also with "mysqlplus"
Thread.new do
loop do
printf "."
sleep 0.1
end
end
sleep 2
puts "[starting MySQL]"
my = Mysql.new("1.2.3.4", "qwe", "qwe", "asd")
puts "[end]"
-------------------
Produces:
....................[starting MySQL]
Now "Ctrl+C" interrupts the script since the blocking MySQL oepration is
running in the parent thread.
--
Iñaki Baz Castillo <[email protected]>
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.