A Result is the base class for several callable subclasses which will receive values at a later point in time, and can also be used standalone without subclassing.
A call to a Result will block until the value is received or the Result is cancelled, which will raise an exception in the caller. A Result may be called by multiple users, before or after the value has been delivered; if the value has been delivered the caller returns with it immediately. A Result’s state may be inspected (pending, running, ready, cancelled). Callbacks can be registered via an Asychron’s .notify method.
An incomplete Result can be told to call a function to compute its value; the function return will be stored as the value unless the function raises an exception, in which case the exception information is recorded instead. If an exception occurred, it will be reraised for any caller of the Result.
Trite example:
R = Result(name="my demo") Thread 1: value = R() # blocks... print(value) # prints 3 once Thread 2 (below) assigns to it Thread 2: R.result = 3 Thread 3: value = R() # returns immediately with 3
You can also collect multiple Results in completion order using the report() function:
Rs = [ ... list of Results or whatever type ... ] ... for R in report(Rs): x = R() # collect result, will return immediately print(x) # print result
Metadata
Release files for cs-result 20171030
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cs.result-20171030.tar.gz | 5.7 kB | Details |
Release files / cs.result-20171030.tar.gz
| Download URL | cs.result-20171030.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
31fc41acf11cec8ada130ff29a6536887e9e1de2fd75adaf41fe7e1a0da88231
|
|
BLAKE2b-256 checksum How to use checksums |
b1a5e1dc8526b34e1acf93d3ef297a2d337e43ae82cfca9fe3de1386dac702da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |