TaskEx: AwaitTaskCorrect / Task.toAsync / Async.ofTask
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 冷清
- 技术栈
- fsharp
- 领域
- backend
调研方向
首先阅读拟议的 API、已被取代的 issue 129 和 139,以及链接的 fslang-suggestion。比较 Equinox、Propulsion 和 FSharp.AWS.DynamoDB 中的规范实现副本。完成的要求是确定一套达成共识的 API,以及适用于共享实现的取消和异常语义。
由索引模型根据 Issue 内容生成。
描述
Replaces https://github.com/fsprojects/FSharp.Control.TaskSeq/issues/129. TaskEx top level issue: https://github.com/fsprojects/FSharp.Control.TaskSeq/issues/139
The default implementation of the Async.AwaitTask methods in FSharp.Core have some key shortcomings:
- when the
Taskfaults, yielding an exception, that exception is typically (always?) wrapped in an egregiousAggregateException - the default implementation does not abort/cancel when the ambient
CancellationTokenof theasyncexpr within whichAsync.AwaitTaskis triggered - cancelling an Async computation should not just abort the processing, it should also propagate a
TaskCancelledExceptionto align with the behavior ofTask
While it can be argued that the current behavior is 'wrong', it's also obvious that breaking it would be untenable, and the semantic differences are beyond what one might cover with subtle overloads and/or adding optional arguments etc.
Current proposed APIs (will be updated inline based on any discussion below):
module Async =
let inline ofTask (t : Task<'t>) : Async<'t> = AwaitTaskCorrect t
let inline ofUnitTask (t : Task) : Async<'t> = AwaitTaskCorrect t
module Task =
let inline toAsync (t : Task<'t>) : Async<'t> = Async.ofTask t
NOTES:
- the above naming is taken from the helpers within
TaskSeq, which are exposed in theFSharp.Controlnamespace. NOTE the current implementations useAsync.AwaitTask, but that was not as a conscious choice, and there is a desire` to fix at least some of the shortcomings noted - given the fact that
taskandasyncare now first class citizens ofFSharp.Core, having anof/topairing would seem to make sense. This is open to debate; not sure the degree to which the prior art is consistent wrt this beyond collection types/modules - There is an
fslang-suggestionregarding this. The purpose of this issue is as a placeholder for potentially filling the gap until this issue can be more thoroughly resolved inFSharp.Coreproper. - Equinox, Propulsion and FSharp.AWS.DynamoDB all have copies of the canonical impl in Eirik's fssnip. Not ruling out tweaks to the semantics, but ideally those libraries, and others, would all share the same semantics
- if this is handled as a
module, one also frequently needs anofUnitTaskalongside as above (Async.AwaitTask is a pair of overloaded methods, which often brings its own issues with intellisense and error messages etc)
- 主要语言
- F#
- 星标
- 111
- 派生
- 13
- 平均合并
- 7 小时 59 分钟
- 30 天内合并 PR
- 3
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fsprojects/FSharp.Control.TaskSeq 的其他 Issue
-
agentic-workflows automation repo-assist
难度 2/5 1-3 小时 新手友好度 70/100
-
agentic-workflows automation repo-assist
难度 1/5 1-3 小时 新手友好度 35/100
fsprojects/FSharp.Control.TaskSeq#476 · 1 条评论 ·
-
bug
难度 4/5 3-5 天 新手友好度 45/100
fsprojects/FSharp.Control.TaskSeq#473 · 1 条评论 · 1 个 reaction ·
-
automation enhancement repo-assist
难度 5/5 一周以上 新手友好度 10/100
-
enhancement needs triage
难度 5/5 一周以上 新手友好度 45/100
查看 fsprojects/FSharp.Control.TaskSeq 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
mksglu/context-mode#1200 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 70/100
-
clawsweeper:needs-maintainer-review clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr impact:auth-provider issue-rating: 🌊 off-meta tidepool P2
难度 1/5 1 小时以内 新手友好度 80/100
-
难度 2/5 1-3 小时 新手友好度 75/100