lwt
lwt copied to clipboard
Deprecate Lwt_main.yield and Lwt_unix.yield?
This is a suggestion. After talking to @aantron on Discourse, I feel we should officially deprecate yield
and related functions using [@@alert deprecate]
, in hope that one day we will merge the two pools into one.
How do you yield then? 🤔
Lwt.pause ()
will do the job. There are currently two pools in the codebase due to the two almost identical mechanisms, but I believe they can be safely merged once every Lwt_unix.yield ()
and Lwt_main.yield ()
is replaced by Lwt.pause ()
.
See
https://github.com/ocsigen/lwt/blob/9cbf3a9c21f181dcd78dabf2117f87a62a2d65cc/src/unix/lwt_main.mli#L45-L52
and https://discuss.ocaml.org/t/lwt-pause-versus-yield/7875.
See https://github.com/ocsigen/lwt/pull/784 for some earlier discussion of this.
TL;DR:
-
Lwt_main.run
treats paused and yielded promises differently: it resolves paused promises twice as often as yielded promises. - This is not an intended difference, but it's a significant difference and it may be significant for several binaries.
I think that, before we release this we should:
- run the tests of all the opam packages that depend on lwt with the modified lwt (I think this is possible through the opam CI in some way)
- notify packages that we break or even give them some patches
- advertise the possibility of the change on discuss (and maybe other channels)
Then if all of that goes well, we can release. It'll need a "breaking change" mention in the changelog.
Maybe we could leverage the opam infrastructure to test if we break some of the tests of the opam packages. I think we should do this (if possible), make upstream commits to all possibly broken packages, and we should make a special mention of this in the changelog (and advertise it in advance on discuss too).
I just updated CHANGES
in the #858 but need help in all other actionable items.
I'll ask some opam wizards about the general test of all dependencies.
Closing this as #917 will complete every actionable items in this issue.