You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The webserver framework we are using is asynchronous. That means request handlers may be stopped and have to wait while other handlers continue their work. This leads to better performance, because while one handler is waiting for some IO operation like networking or access to the filesystem, another handler may do useful work in the meantime.
You may have noticed the keywords asnyc and await in the code base. An asnyc function can be stopped and wait for some other thing, while other tasks make progress. The await keyword is used to await the completion of such a task, like networking or filesystem access.
what to do
Even though we're technically using async, our filesystem access is using the blocking1 functions from std. Our async runtime tokio has its own functions for accessing the filesystem in an asynchronous manner. Unlike the blocking operations from std, the return values of such asynchronous filesystem operations need to be awaited with .await. See the documentation of tokio for examples.
Replace the use of std::fs with tokio::fs.
Footnotes
"blocking" is the opposite of "async". When a blocking operation is waiting for something, like the filesystem, other tasks are blocked from making progress. We don't want that! ↩
The text was updated successfully, but these errors were encountered:
context
The webserver framework we are using is asynchronous. That means request handlers may be stopped and have to wait while other handlers continue their work. This leads to better performance, because while one handler is waiting for some IO operation like networking or access to the filesystem, another handler may do useful work in the meantime.
You may have noticed the keywords
asnyc
andawait
in the code base. Anasnyc
function can be stopped and wait for some other thing, while other tasks make progress. Theawait
keyword is used to await the completion of such a task, like networking or filesystem access.what to do
Even though we're technically using
async
, our filesystem access is using the blocking1 functions fromstd
. Our async runtimetokio
has its own functions for accessing the filesystem in an asynchronous manner. Unlike the blocking operations fromstd
, the return values of such asynchronous filesystem operations need to be awaited with.await
. See the documentation of tokio for examples.Replace the use of
std::fs
withtokio::fs
.Footnotes
"blocking" is the opposite of "async". When a blocking operation is waiting for something, like the filesystem, other tasks are blocked from making progress. We don't want that! ↩
The text was updated successfully, but these errors were encountered: