Blocking wait for Lwt promise

Is it possible to wait for an Lwt promise in a synchronous manner?

blocking_wait : 'a Lwt.t -> 'a

I realize this is not idiomatic and goes against the purpose of Lwt. However, I need to use Cohttp in a project that does not support asynchronous execution yet.

You can use I’ve done the same for quick cohttp additions to an otherwise synchronous codebase. There is a definite performance cost but that may or may not be relevant for your use case.

The documentation is here.

Thanks @hcarty, this is just what I was looking for!

1 Like