I did the same (mechanize + mysql) and I solved it by wrapping my mysql calls with the begin / rescue / end clause:
begin
mysql_insert data
rescue Interrupt, Errno::EINTR
mysql_close connection
connection = mysql_connect
retry
end
Please note that this puts your code in an infinite loop, if you use it in something real, I would recommend placing some kind of limiter on it. All mysql_ * are my own methods.
source
share