Commit Graph

20 Commits

Author SHA1 Message Date
Jacek Sieka f5ff9e32ca
introduce asyncraises in transports/asyncsync (#470)
With these fixes, `transports`/`asyncsync` correctly propagate and document their raises information - generally, most transport functions (send etc) raise `TransportError` and `CancelledError` - `closeWait` is special in that it generally doesn't fail.

This PR introduces the syntax `Future[void].Raises([types])` to create the `InternalRaisesFuture` type with the correct encoding for the types - this allows it to be used in user code while retaining the possibility to change the internal representation down the line.

* introduce raising constraints on stream callbacks - these constraints now give a warning when called with a callback that can raise exceptions (raising callbacks would crash 
* fix fail and its tests, which wasn't always given a good generic match
* work around nim bugs related to macro expansion of generic types
* make sure transports raise only `TransportError`-derived exceptions (and `CancelledError`)
2023-11-15 09:38:48 +01:00
Jacek Sieka e706167a53
add connect cancellation test (#444) 2023-09-05 13:41:52 +03:00
Jacek Sieka 229de5f842
Compile-time configuration (#371)
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.
2023-03-31 07:35:04 +02:00
Jacek Sieka 4abd7a5645
exception tracking (#166)
* 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
2021-03-24 10:08:33 +01:00
Eugene Kabanov b5915ecd29
Small fixes (#134)
* Fix cancellation behavior.
Fix some compilation warnings.

* Fix cancelAndWait() and add proper documentation.

* Add completed(Future) and done(Future) calls to check if Future[T] completed without an error.

* Add stepsAsync() and tests.

* Fix comments.

* Fix new primitive comment, to avoid usage for task switches.
2020-11-13 14:22:58 +02:00
cheatfate fb00b20cfa
Fix all compilation warnings for 1.0.2.
Fix all related problems.
2019-10-29 23:19:41 +02:00
cheatfate 29d9274e03
Fix some compilation warnings. 2019-10-24 16:01:57 +03:00
cheatfate 6e7a753793
Fix for Windows server close procedure. 2019-05-09 20:59:15 +03:00
cheatfate 80ee289847
Fix rarely appearing Windows bug with close(transport).
Add tests for it.
Add fromProc for all Future[T] in transports.
Add testall to improve tests speed.
Bump version to 2.2.4.
2019-03-31 00:31:10 +02:00
Mamy Ratsimbazafy 9f15c6b752
Rebrand Asyncdispatch2 to Chronos [WIP] (#20)
* Update file headers, copyright date

* Rename files and hopefully fix nimble

* Forgot to change path in tests

* Update readme
2019-02-06 15:49:11 +01:00
cheatfate 530905f276 Fix #8 and related issues, added more tests for it.
Fix Unix connection failed bug.
2018-08-24 15:20:08 +03:00
cheatfate 525aaf6837 Comment out asyncmacro2 skipStmtList().
Many changes in datagram.nim.
Fixed testdatagram.nim.
Fixed testserver.nim.
2018-06-14 09:49:59 +03:00
cheatfate 978203691e Add `var` arguments to GC procedures, to disallow runtime exceptions. 2018-06-11 23:50:45 +03:00
cheatfate d2b93f309b Fix createStreamServer[T]().
Add test for bug with createStreamServer[T]().
2018-06-11 22:54:08 +03:00
cheatfate deb22a8b4a Fix Linux. 2018-06-11 02:21:36 +03:00
cheatfate 5815897de6 Fix windows asyncLoop.
Fix OSError -> TransportOSError.
Add inherited objects initialization.
Add tests for inherited objects.
2018-06-11 02:08:17 +03:00
cheatfate 3eb4a00397 Fix testserver.nim according to latest API changes. 2018-06-07 00:38:13 +03:00
cheatfate a834cb1a00 Changed server behavior.
Removed pause function.
Updated testserver.
2018-06-04 12:57:17 +03:00
cheatfate ac32dd24c3 Fix compilation error in testserver.nim. 2018-06-02 17:30:36 +03:00
cheatfate 6985626e1c Test teststream2 renamed to testserver.
Fix compilation errors.
2018-05-31 11:10:32 +03:00