Comments (4)
you can:
proc process() {.async.} =
raise (ref ValueError)()
proc ignoreExceptions(fut: Future[void]): Future[void] {.async.} =
try:
await fut
except CatchableError as exc:
debugEcho "fail"
asyncSpawn ignoreExceptions process()
asyncSpawn
/asyncCheck
exist to deliberately check for uncaught exceptions - just like raising in a thread without catching would terminate the program. discard process(...)
will also make chronos ignore exceptions though it's poor style.
from nim-chronos.
if the user uses asyncSpawn
, that's nothing you can control - there's no way to prevent that from raising a Defect
- this is by design, the program would be in an inconsistent state at that point (because it would try to raise an exception through the processing loop which leads to resource leaks et al. This is a contributing reason why asyncdispatch has so many leaks and problems for example.
from nim-chronos.
Check, so this sentence of mine is incorrect:
I would like to be able to catch ValueError (or an exception containing it) outside of asyncProc, as "normal" errors such as this do not represent a sufficiently erroneous case to crash the thread to me.
Exceptions thrown by running the dispatcher instead of by some awaited future are a sufficiently erroneous case as you pointed out, due to potential resource leaks etc.
If I want to protect the user therefore my best choice is likely to mandate them not raise an exception, e.g via using raises: []
from nim-chronos.
mandate them not raise an exception,
indeed - it is likely asyncSpawn
will start showing a compile-time warning whenever someone uses it without raises: []
. asyncCheck
is deprecated already for similar reasons.
from nim-chronos.
Related Issues (20)
- chronos is not available in Nim Playground? HOT 2
- httpclient: The content of HostHeader is incorrect when redirecting to a different host HOT 1
- Write to `Future.internalValue` directly in macro-translated code
- `getAcceptInfo` can raise an unlisted exception: ref ValueError HOT 2
- Apparent garbage collect of localCopy in datagram sendTo before data gets send in writeDatagramLoop HOT 2
- Cycle-based memory Leak under --mm:arc HOT 1
- chronos/threadsync errors when compiling documentation
- bug: TokenBucket update calculates wrong with lastUpdate timestamp HOT 1
- Reading a file asynchronously? HOT 1
- Async proc: both Option[seq[T]] and Opt[seq[T]] as return type and one of the params is generic, failed to compile with Nim-devel HOT 1
- Completing `Futures` in refc may have unexpected behavior HOT 1
- `cancelAndWait` on `or` triggers deadlock
- `SIGSEGV` in `asyncTest`-derived scenario (also, in `asyncTest`) HOT 5
- Can't compile on GCC 14 HOT 1
- ambiguous identifier: `'Result'` HOT 2
- Change header size limits HOT 2
- Its impossible to specify Future[T].Raising([]) as argument.
- Why does this usage of asyncSpawn and ThreadSignalPtr leak memory? HOT 4
- Compilation errors with `-d:chronosHandleException` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nim-chronos.