aio-libs / aio-libs/aiohttp

WebSocketResponse's timeout does not apply to send_bytes/send_json/send_str calls.

オープン
#2,310 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Python
スター
16.5k
フォーク
2.4k
平均マージ
17時間 22分
マージ済み PR(30日)
212

説明

## Long story short

This is more of a question. Is this behaviour by design?

We have to timeout-related parameters on WebSocketResponse:

* `timeout`
* `receive_timeout`

The `receive_timeout` works for all receive operations. Consequently, I assumed that the `timeout` parameter worked for all send operations. Apparently, I was mistaken. The documentation is not so clear about this.

From the look of the implementation, `timeout` is actually only used in the `close()` call.

## Expected/Actual behaviour

I expected that the `timeout` parameter applied to the `send_bytes`/`send_json`/`send_str` calls. It does not.

## Discussion

Currently, I simply wrap my `send_x` calls in `with Timeout(...)`. It's not that much effort but it would be nice to see this directly implemented in aiohttp.

I can see two options:

* Let `timeout` parameter apply to the `send_x` calls
* Add a `send_timeout` parameter to the WebSocketResponse that applied a timeout to the `send_x` calls

This also relates to #2309. In my actual implementation, the `send_x` calls are submitted to the event loop in a fire-and-forget fashion. Consequently, if the connection is abruptly cut, said `send_x` calls are left lingering and never cancelled. By using a timeout, said calls will time out and not fill up in memory.

## Your environment

Aiohttp 2.2.3 and Python 3.6.1.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。