0 down vote favorite I was following the book Nim in Action.
In Chapter 3, there was an example like this:
import asyncdispatch, asyncfile
proc readFiles() {.async.} =
var file = openAsync("/tmp/hello.py", fmReadWrite)
let data = await file.readAll()
echo(data)
await file.write("Hello!\n")
file.close()
waitFor readFiles()
Run
The only change I've made to the example was replacing the file name with one
that existed on my system.
The code was supposed to output the content of the opened file and write
"Hello!n" to it.
But when I ran it, the readAll always returned an empty string, which I
verified by add assert len(data) > 0.
What can I change to do async read successfully?