agronholm / agronholm/anyio

Please enable deterministic scheduling in the pytest plugin under Trio

オープン
#581 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Python
スター
2.5k
フォーク
260
平均マージ
2日 8時間
マージ済み PR(30日)
19

説明

### Things to check first

- [X] I have searched the existing issues and didn't find my feature already requested there

### Feature description

I request a pytest plugin feature to enable deterministic testing, similar to what is done under [pytest-trio](https://github.com/python-trio/pytest-trio). I do not see any easy way to do this for the asyncio backend.

I have made a [feature request in trio](https://github.com/python-trio/trio/issues/2675) to enable keywording of this as a backend feature, which is a far preferable way of implementing the same thing.

### Use case

Deterministic scheduling is very handy in many test scenarios. Trio allows somewhat-deterministic scheduling through monkey-patching its event loop generator to set `_ALLOW_DETERMINISTIC_SCHEDULING` and replacing its random-value generator with a seeded one. Both of which are done by `pytest-trio`, but not by the AnyIO pytest plugin. I say "somewhat-deterministic" because differences in thread timing based on CPU utilization can still introduce stochastic elements, even in fully mocked-up code.

AFAIK, it's not similarly easy to achieve deterministic-ish scheduling with asyncio, although I have seen code that injects additional jobs into the event loop to make a state machine of sorts. One thing that attracted me to AnyIO is to do deterministic (and non-performant) testing with `trio` and then use `asyncio+uvloop` in production.

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

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

評価

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

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

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