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
We've been porting our threadpool based TCP and UDP servers over to chronos instead, which has been quite lovely for the most part.
One thing I've hit though, is the inability to read a file from the filesystem in an async manner?
I've attempted to use std/asyncfile with chronos instead of asyncdispatch, but unless I'm doing something obviously wrong, it seems to have an issue with the Future type from asyncfile.readAll not matching what the chronos await expects.
Please excuse the gross raises.
procloadFirmware(device: DeviceDetails, version: string): Future[(string, int, FirmwareState)] {.async: (raises: [Exception]).}=#TODO: Add in parsing of board ID to check for firmware bloblet fwPath =getCurrentDir() /"firmware"/$device.boardFamily /$device.boardRevision / version &".bin"
log.debug("Firmware loaded path: "& fwPath, device.boardId)
var fwStream =openAsync(fwPath, fmRead)
ifisNil(fwStream):
raisenewException(IOError, "Cannot read binary firmware file, please check it exists...")
log.info("Reading firmware data into memory...")
var fwDataLen =getFileSize(fwPath).intvar data =await fwStream.readAll()
fwStream.close()
return (data, fwDataLen, fwRead)
This gives the following error:
type mismatch: got <Future[system.string]>
but expected one of:
template await[T, E](fut: InternalRaisesFuture[T, E]): T
first type mismatch at position: 1
required type for fut: InternalRaisesFuture[await.T, await.E]
but expression 'readAll(fwStream)' is of type: Future[system.string]
template await[T](f: Future[T]): T
first type mismatch at position: 1
required type for f: Future[await.T]
but expression 'readAll(fwStream)' is of type: Future[system.string]
expression: await readAll(fwStream)
Any ideas? Am I missing something obvious within chronos?
The text was updated successfully, but these errors were encountered:
We've been porting our
threadpool
based TCP and UDP servers over tochronos
instead, which has been quite lovely for the most part.One thing I've hit though, is the inability to read a file from the filesystem in an async manner?
I've attempted to use
std/asyncfile
withchronos
instead ofasyncdispatch
, but unless I'm doing something obviously wrong, it seems to have an issue with theFuture
type fromasyncfile.readAll
not matching what the chronosawait
expects.Please excuse the gross raises.
This gives the following error:
Any ideas? Am I missing something obvious within chronos?
The text was updated successfully, but these errors were encountered: