-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
forking breaks lwt-io if happens after Lwt_main.run #970
Comments
If you insert More generally I have no idea why Lwt provides |
Possibly |
Yes, it was our workaround to use
Yep, in the end we had to switch to lwt-parallel library instead of using fork directly. This library addresses this issue by creating a process snapshot before lwt is used. Probably, this is the only safe way of using |
If I use
Lwt_unix.fork
(orUnix.fork
) after any successful invocation ofLwt_main.run
(evenLwt_main.run (Lwt.return ())
), then in all consecutive forks the lwt-io system will not work in the child processes. The peculiar thing here is that this happens only if I do not perform any Lwt-specific stuff in the first fork1 (i.e., this fork is totally lwt-independent). The version that I am using is 5.6.1.Here is the code to reproduce, put it into
run.ml
,and the dune file for your convenience,
FWIW, I also tried using the libev engine, with
select
,poll
, andepoll
backends, they all exhibit the same behavior.1)) In terms of the above example, it means that if I will remove
fork_and_wait
then I can dofork_and_talk
as many times as I like. It is only the peculiar combination of running anyLwt_main.run
(even the trivial one that apparently shall not have any observable side-effects) and doing a fork (even withUnix.fork
) that doesn't touch any lwt-related stuff. Unfortunately, this combination is quite common in large applications.The text was updated successfully, but these errors were encountered: