pyrlang.pattern_match

Patterns for selective receive and for GenServer handlers.

pyrlang.pattern_match.always_match(_)

A pattern function that accepts every message.

pyrlang.pattern_match.handle_do_nothing(data)

A handler that returns the message unchanged.

class pyrlang.pattern_match.Pattern(match_fun=None, match_success_fun=None)

Bases: object

A pattern is a pair of matcher function, and an async handler function. Matcher will be checked with the incoming message, and if it returned True, the async handler will be invoked. This is typically done in the process receive handler, but potential uses are not limited to it.

is_match(data)

This checks whether ‘data’ matches something we expect.

async on_match_success(data)

This should be called on the successful match. The handler may return a value or an awaitable; an awaitable is awaited.

class pyrlang.pattern_match.Match(patterns=None)

Bases: object

Match class to mimic an aid in the erlang pattern matching used in calls and, in our case more importantly, in receive

is_match(data)

The first pattern that matches data, or False.