How to use the outcome.Outcome function in outcome

To help you get started, we’ve selected a few outcome examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Fuyukai / curious / curious / core / event / manager.py View on Github external
raise
            except Exception as e:
                # something bad happened, set exception and exit
                logger.exception("Exception in wait_for predicate!")
                # signal that an error happened
                await p.set(outcome.Error(e))
                raise ListenerExit
            else:
                # exit now if result is true
                if res is True:
                    await p.set(outcome.Value(args))
                    raise ListenerExit

        self.add_temporary_listener(name=event_name, listener=listener)
        try:
            output: outcome.Outcome = await p.wait()
        except Exception:  # cancellations or timeouts
            self.remove_listener_early(event_name, listener=listener)
            raise

        result = output.unwrap()

        # unwrap tuples, if applicable
        if len(result) == 1:
            return result[0]
        return result

outcome

Capture the outcome of Python function calls.

MIT OR Apache-2.0
Latest version published 1 year ago

Package Health Score

71 / 100
Full package analysis