pythread

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 8 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

View Source
var ErrSemaphoreReleasedTooManyTimes = errors.New("Semaphore released too many times")

ErrSemaphoreReleasedTooManyTimes is the ValueError of an over released BoundedSemaphore

Functions

func GoroutineID

func GoroutineID() uint64

Identifier of the calling goroutine, the Go form of threading.get_ident

func Monotonic

func Monotonic() float64

Seconds on the system monotonic clock like time.monotonic, counted from boot so a zero stamp reads as long ago

Types

type BoundedSemaphore

type BoundedSemaphore struct {
	// contains filtered or unexported fields
}

BoundedSemaphore is threading.BoundedSemaphore, a counter that refuses release past its initial value

func NewBoundedSemaphore

func NewBoundedSemaphore(value int) *BoundedSemaphore

Semaphore holding value free slots

func (*BoundedSemaphore) Acquire

func (s *BoundedSemaphore) Acquire(blocking bool) bool

Takes a slot, without blocking false when none is free

func (*BoundedSemaphore) Release

func (s *BoundedSemaphore) Release() error

Returns a slot, the ValueError when every slot is already free

type Event

type Event struct {
	// contains filtered or unexported fields
}

Event is threading.Event, a flag goroutines set once and wait on

func (*Event) Clear

func (e *Event) Clear()

Clears the flag so later waits block again

func (*Event) IsSet

func (e *Event) IsSet() bool

Reports whether the flag is set

func (*Event) Set

func (e *Event) Set()

Sets the flag and wakes every waiter

func (*Event) Wait

func (e *Event) Wait(timeout float64) bool

Blocks until the flag is set or the timeout in seconds passes, a negative timeout waits forever

func (*Event) Waiter

func (e *Event) Waiter() <-chan struct{}

Channel closed once the flag is set, a select arm for the asyncio Event wait of the Python

type Local

type Local struct {
	// contains filtered or unexported fields
}

Per goroutine value slot, the threading.local form keyed by the calling goroutine

func (*Local) Delete

func (l *Local) Delete()

Forgets the calling goroutine's value so a finished goroutine leaves nothing behind

func (*Local) Get

func (l *Local) Get() (any, bool)

Value the calling goroutine stored, false when it stored none

func (*Local) Set

func (l *Local) Set(v any)

Stores the value for the calling goroutine only

type RLock

type RLock struct {
	// contains filtered or unexported fields
}

RLock is threading.RLock, reacquirable by the goroutine that holds it and released after as many unlocks

func (*RLock) Lock

func (l *RLock) Lock()

Blocks until the lock is free or already held by this goroutine, then bumps the hold count

func (*RLock) TryLockFor

func (l *RLock) TryLockFor(timeout time.Duration) bool

Acquires like Lock but gives up once timeout passes, the acquire(timeout=...) form

func (*RLock) Unlock

func (l *RLock) Unlock()

Drops one hold and frees the lock for other goroutines at zero, panicking for a non owner like RuntimeError

Jump to

Keyboard shortcuts

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