* Fix waitFor() should not exit earlier last callback will be scheduled.
* Tune tests to use less memory.
* Fix `testutils`. There is no more last poll() needed.
* Update chronos/internal/asyncfutures.nim
---------
Co-authored-by: Jacek Sieka <jacek@status.im>
* Exception tracking v2
* some fixes
* Nim 1.2 compat
* simpler things
* Fixes for libp2p
* Fixes for strictException
* better await exception check
* Fix for template async proc
* make async work with procTy
* FuturEx is now a ref object type
* add tests
* update test
* update readme
* Switch to asyncraises pragma
* Address tests review comments
* Rename FuturEx to RaiseTrackingFuture
* Fix typo
* Split asyncraises into async, asyncraises
* Add -d:chronosWarnMissingRaises
* Add comment to RaiseTrackingFuture
* Allow standalone asyncraises
* CheckedFuture.fail type checking
* First cleanup
* Remove useless line
* Review comments
* nimble: Remove #head from unittest2
* Remove implict raises: CancelledError
* Move checkFutureExceptions to asyncfutures2
* Small refacto
* small cleanup
* Complete in closure finally
* cleanup tests, add comment
* bump
* chronos is not compatible with nim 1.2 anymore
* re-add readme modifications
* fix special exception handlers
* also propagate excetion type in `read`
* `RaiseTrackingFuture` -> `InternalRaisesFuture`
Use internal naming scheme for RTF (this type should only be accessed
via asyncraises)
* use `internalError` for error reading
* oops
* 2.0 workarounds
* again
* remove try/finally for non-raising functions
* Revert "remove try/finally for non-raising functions"
This reverts commit 86bfeb5c97.
`finally` is needed if code returns early :/
* fixes
* avoid exposing `newInternalRaisesFuture` in manual macro code
* avoid unnecessary codegen for `Future[void]`
* avoid reduntant block around async proc body
* simplify body generation for forward declarations with comment but no
body
* avoid duplicate `gcsafe` annotiations
* line info for return at end of async proc
* expand tests
* fix comments, add defer test
---------
Co-authored-by: Jacek Sieka <jacek@status.im>
* Add callTick and stream cancellation tests.
* Fix stepsAsync() test.
* Cancellation changes.
* Update and add more cancellation tests.
* Fix Posix shutdown call to handle ENOTCONN error.
* With new changes to to cancellation its now possible.
* Refactor testsoon.nim to not produce artifacts after tests are finished.
* Debugging MacOS issue.
* Adjust flaky test times.
* Fix issue.
* Add test for issue #334 which was also addressed in this PR.
Avoid `break` in problematic test.
* Add noCancelWait() call which prohibits cancellation.
Fix closeWait() calls to use noCancelWait() predicate.
Adding sleep to flaky MacOS test.
* Remove all debugging echoes.
* Fix cancelAndWait() which now could perform multiple attempts to cancel target Future (mustCancel behavior).
* Fix issues revealed by switch to different cancelAndWait().
* Address review comments.
* Fix testutils compilation warning.
* Rename callTick() to internalCallTick().
* Add some documentation comments.
* Disable flaky ratelimit test.
* Rename noCancelWait() to noCancel().
Address review comments.
* FutureState.Finished -> FutureState.Completed (to avoid name clash
with `proc finished` which means not-pending)
* deprecate `done` - to avoid additional confusion over completed vs
finished
* remove ad leftovers in stack trace formatting
* avoid some generic bloat
* avoid unnecessary allocations in `race`/`one`
This PR moves all compile-time configuration to a single module,
simplifying documentation and access to these features.
Upcomfing features may be enabled either individually, or through a new
`chronosPreviewV4` catch-all designed to allow code to be prepared for
increased strictness in future chronos releases.
`-d:chronosDebug` may be used to enable the existing debugging helpers
together.
* Change Future identifier type from `int` to `uint64`.
* Fix compilation error and tests.
* Add integer overflow test, to avoid confusion with next Nim versions, we expect that unsigned integers do not raise any exceptions if overflow happens.
* Switch from `uint64` to `uint` type.
* Add `uint` overflow tests.
* exception tracking
This PR adds minimal exception tracking to chronos, moving the goalpost
one step further.
In particular, it becomes invalid to raise exceptions from `callSoon`
callbacks: this is critical for writing correct error handling because
there's no reasonable way that a user of chronos can possibly _reason_
about exceptions coming out of there: the event loop will be in an
indeterminite state when the loop is executing an _random_ callback.
As expected, there are several issues in the error handling of chronos:
in particular, it will end up in an inconsistent internal state whenever
the selector loop operations fail, because the internal state update
functions are not written in an exception-safe way. This PR turns this
into a Defect, which probably is not the optimal way of handling things
- expect more work to be done here.
Some API have no way of reporting back errors to callers - for example,
when something fails in the accept loop, there's not much it can do, and
no way to report it back to the user of the API - this has been fixed
with the new accept flow - the old one should be deprecated.
Finally, there is information loss in the API: in composite operations
like `poll` and `waitFor` there's no way to differentiate internal
errors from user-level errors originating from callbacks.
* store `CatchableError` in future
* annotate proc's with correct raises information
* `selectors2` to avoid non-CatchableError IOSelectorsException
* `$` should never raise
* remove unnecessary gcsafe annotations
* fix exceptions leaking out of timer waits
* fix some imports
* functions must signal raising the union of all exceptions across all
platforms to enable cross-platform code
* switch to unittest2
* add `selectors2` which supercedes the std library version and fixes
several exception handling issues in there
* fixes
* docs, platform-independent eh specifiers for some functions
* add feature flag for strict exception mode
also bump version to 3.0.0 - _most_ existing code should be compatible
with this version of exception handling but some things might need
fixing - callbacks, existing raises specifications etc.
* fix AsyncCheck for non-void T
This reverts commit 284d677815.
There is no rough consensus for how this should be implemented and
whether it's needed indeed - a use case that cannot be solved with
a queue or a lock/event should be identified before pursuing this
functionality.