Help me with converting async to sync

I know this is weird, but I don't want to run my code asynclonously.

I'm on poem lib, and working in "poem/hello-world".
I removed async prefix on main, and remove await and its built successfully. but shutdown immediately. How do I make it run synclonously?

It isn't. It's perfectly fine to write blocking code if that is what your use case requires.

In reality, if you've got an entire async-based web framework, as it looks like Poem is, then you won't realistically be able to just convert it to blocking, because the major pieces will likely be async all the way down. You will not be able to have its async-dependent parts run without an async runtime.

That said, you can wait for the result of individual async operations using futures::block_on().


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.