Ruby mysql mysql2 和 datamapper 如何重新连接
我有一些东西在不断地运行,进行定期查询。我使用了 DataMapper(尽管我通过它执行原始 SQL)和 mysql2。
无论使用哪一种,它们偶尔都会停止工作。我相信这是因为服务器出现问题或其他原因。
尽管如此,一切都会停止。每个线程上的执行仅在查询行处停止,这就是结束。
有没有办法告诉他们重新连接?或者,如果做不到,我可以自己做吗?我一直在尝试使用超时,但超时似乎也有点冻结(它进入块并且永远不会离开,既不是通过引发错误,也不是通过自然完成)。
我只是希望查询(如果失败)在下一次继续传递,重试,并在必要时重新连接到服务器。我该怎么做?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论