Ruby mysql mysql2 AND datamapper how to reconnect
I have something running constantly doing periodic queries. I have used both DataMapper (though I'm doing raw SQL through it) and mysql2.
Using either, occasionally they stop working. I believe it's because the server hiccuped or something.
Nonetheless, everything grinds to a halt, then. Execution on each thread just stops at the query line and that's the end of that.
Is there a way to tell them to reconnect? Or, failing that, can I do it myself. I've been trying using timeout
, but timeout seems to sort of freeze as well (it enters the block and never leaves, neither via raising an error nor through natural completion).
I simply want the queries, if they fail, to pass on by and on the next time around, try again, reconnecting to the server if necessary. How can I do this?
精彩评论