pydeadline

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PollUntil

func PollUntil[T any](pred func() (T, bool), timeout, interval time.Duration) T

Calls pred every interval until it holds or the timeout passes, the last sleep cut to the time left

func Start

func Start(ctx context.Context, fn func(ctx context.Context) (any, error), label string) <-chan Outcome

Starts fn on its own goroutine and delivers its value, error or recovered panic on the returned channel

Types

type Hooks

type Hooks struct {
	Now         func() time.Time
	MarkSuspect func()
	OnTimeout   func()
}

Hooks of one bounded run, the clock and the two expiry callbacks

type Outcome

type Outcome struct {
	Value any
	Err   error
}

Value, error or recovered panic of a bounded worker

type Result

type Result struct {
	TimedOut bool
	Value    any
	Elapsed  time.Duration
	Timeout  time.Duration
	Bounded  bool
	Label    string
}

Result is the outcome of a bounded operation, operation errors never land here

func RunBounded

func RunBounded(ctx context.Context, fn func(ctx context.Context) (any, error), timeout time.Duration, bounded bool, label string, hooks Hooks) (Result, error)

Runs fn on a worker keeping the caller context values, abandoning the worker uncancelled on expiry

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL