Documentation
¶
Index ¶
- type ContextAwareMutex
- type InterpreterTicket
- type MultiInterpreterRuntime
- func (r *MultiInterpreterRuntime) Acquire(ctx context.Context) (*InterpreterTicket, error)
- func (r *MultiInterpreterRuntime) Apply(token *InterpreterTicket, _ context.Context, f func() error) error
- func (r *MultiInterpreterRuntime) Map(ctx context.Context, f func(t *InterpreterTicket) error) error
- func (r *MultiInterpreterRuntime) Release(token *InterpreterTicket) error
- func (r *MultiInterpreterRuntime) Start(ctx context.Context) error
- func (r *MultiInterpreterRuntime) Stop(ctx context.Context) error
- type Runtime
- type SingleInterpreterRuntime
- func (r *SingleInterpreterRuntime) Acquire(ctx context.Context) (*InterpreterTicket, error)
- func (r *SingleInterpreterRuntime) Apply(ticket *InterpreterTicket, _ context.Context, f func() error) error
- func (r *SingleInterpreterRuntime) Map(ctx context.Context, f func(token *InterpreterTicket) error) error
- func (r *SingleInterpreterRuntime) Release(ticket *InterpreterTicket) error
- func (r *SingleInterpreterRuntime) Start(ctx context.Context) error
- func (r *SingleInterpreterRuntime) Stop(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextAwareMutex ¶
type ContextAwareMutex struct {
// contains filtered or unexported fields
}
A ContextAwareMutex implements a mutex lock that allows for an optional context to be provided so a caller can control if they want a deadline or timeout.
func NewContextAwareMutex ¶
func NewContextAwareMutex() *ContextAwareMutex
func (*ContextAwareMutex) AssertLocked ¶
func (c *ContextAwareMutex) AssertLocked()
AssertLocked panics if the ContextAwareMutex is not currently locked by someone.
func (*ContextAwareMutex) Lock ¶
func (c *ContextAwareMutex) Lock() error
Lock the mutex using a background context.
func (*ContextAwareMutex) LockWithContext ¶
func (c *ContextAwareMutex) LockWithContext(ctx context.Context) error
LockWithContext will attempt to take the lock but uses the provided context.Context to allow cancellation.
func (*ContextAwareMutex) Unlock ¶
func (c *ContextAwareMutex) Unlock()
Unlock the mutex. Panics if the mutex is not currently locked in order to speed up debugging.
type InterpreterTicket ¶
type InterpreterTicket struct {
// contains filtered or unexported fields
}
An InterpreterTicket represents ownership of the interpreter of a particular Runtime. Other than its id, it's opaque to the user.
func (*InterpreterTicket) Id ¶
func (i *InterpreterTicket) Id() int64
Id provides a unique (to the backing Runtime) identifier for an interpreter. The caller may use this for identifying if they're re-using an interpreter.
type MultiInterpreterRuntime ¶
type MultiInterpreterRuntime struct {
// contains filtered or unexported fields
}
MultiInterpreterRuntime creates and manages multiple Python sub-interpreters.
func (*MultiInterpreterRuntime) Acquire ¶
func (r *MultiInterpreterRuntime) Acquire(ctx context.Context) (*InterpreterTicket, error)
func (*MultiInterpreterRuntime) Apply ¶
func (r *MultiInterpreterRuntime) Apply(token *InterpreterTicket, _ context.Context, f func() error) error
func (*MultiInterpreterRuntime) Map ¶
func (r *MultiInterpreterRuntime) Map(ctx context.Context, f func(t *InterpreterTicket) error) error
Map a function fn over all the interpreters, one at a time. Useful for initializing all interpreters to a given state.
func (*MultiInterpreterRuntime) Release ¶
func (r *MultiInterpreterRuntime) Release(token *InterpreterTicket) error
type Runtime ¶
type Runtime interface {
// Start the Python runtime.
Start(ctx context.Context) error
// Stop the Python runtime, removing all interpreter state.
Stop(ctx context.Context) error
// Acquire ownership of an interpreter until Release is called, providing
// a ticket on success or returning err on error.
Acquire(ctx context.Context) (ticket *InterpreterTicket, err error)
// Release ownership of an interpreter identified by the given
// InterpreterTicket.
Release(token *InterpreterTicket) error
// Apply a function f over the interpreter described by the given
// InterpreterTicket.
Apply(token *InterpreterTicket, ctx context.Context, f func() error) error
// Map a function f over all possible interpreters.
// In the case of multiple interpreters, an error aborts mapping over the
// remainder.
Map(ctx context.Context, f func(ticket *InterpreterTicket) error) error
}
A Runtime for a Python interpreter.
type SingleInterpreterRuntime ¶
type SingleInterpreterRuntime struct {
// contains filtered or unexported fields
}
SingleInterpreterRuntime provides an implementation for using main Python interpreter.
func NewSingleInterpreterRuntime ¶
func NewSingleInterpreterRuntime(exe string, logger *service.Logger) (*SingleInterpreterRuntime, error)
func (*SingleInterpreterRuntime) Acquire ¶
func (r *SingleInterpreterRuntime) Acquire(ctx context.Context) (*InterpreterTicket, error)
func (*SingleInterpreterRuntime) Apply ¶
func (r *SingleInterpreterRuntime) Apply(ticket *InterpreterTicket, _ context.Context, f func() error) error
func (*SingleInterpreterRuntime) Map ¶
func (r *SingleInterpreterRuntime) Map(ctx context.Context, f func(token *InterpreterTicket) error) error
func (*SingleInterpreterRuntime) Release ¶
func (r *SingleInterpreterRuntime) Release(ticket *InterpreterTicket) error