snower / TorMySQL

The highest performance asynchronous MySQL driver by PyMySQL
MIT License
308 stars 63 forks source link

库不能设置sql的响应超时时间 #39

Closed dsseter closed 5 years ago

dsseter commented 6 years ago

read_timeout = 1, write_timeout= 1, select expression: select sleep(10) from table_name limit 1; thanks

snower commented 5 years ago

Read_timeout and write_timeout are not supported. If read_timeout and write_timeout are supported for each read and write, IOLoop timeout needs to be registered. This is very important for performance, so if you need it, you can manually register a timeout in IOLoop to execute close(True) before executing. Close this connection and close this query. I think based on performance considerations, most of the reads and writes do not need to time out. It is a better solution for the application layer to decide whether to timeout. Thank you.

不支持read_timeout和write_timeout,如果每次读写都支持read_timeout和write_timeout需要注册IOLoop timeout,这是非常影响性能的,所以如果有需要你可以手动在execute之前在IOLoop中注册一个timeout来执行close(True)关闭这个连接,从而关闭这次查询,我想基于性能考虑,大部分读写并不需要超时,由应用层决定是否超时是一个更好的方案。 谢谢。