API Documentation

Processes

class paragram.Process

The base class of all paragram Process objects.

Member :

error

If a process terminates with an error, this attribute is set to the exception instance. In all other cases, it is None

is_alive()

Typically, wait() is a better choice.

send(*msg)

Send a message to this process

terminate(error=None)

Send an exit message to this process

wait(timeout=None)

Wait for this process to finish

class paragram.process.base_process.LocalProcess

Code running inside a process can use these methods on the process object, in addition to the public methods provided by paragram.Process

Member :

receive

Used to set a new receiver, with either of two syntaxes:

>>> process.receive[message] = handler

or:

>>> @process.receive(message)
>>> def handler(...):
...     # ...

For more information, see Handling Messages

spawn(target, name=None, link_to=None, kind=None, args=(), kwargs={})

Spawn a new process. target is called with the newly-created process as its first argument, followed by args and kwargs (if present).

target is responsible for setting up any receivers on the process and sending any initial messages. After that, the process will run until terminated.

Parameters:
  • target – The callable that will be used to init this process.
  • name – Name of this process, for use in logging, etc.
  • link_to – used by spawn_link() to link the newly-created process to an existing process.
  • kind – The class of this process. Should be either OSProcess or ThreadProcess.
  • args – extra arguments to pass to target
  • kwargs – extra keyword arguments to pass to target

This function calls spawn() with all provided arguments, setting link_to to self.

paragram.OSProcess

A paragram process implemented as a separate operating system process.

paragram.ThreadProcess

A paragram process implemented as a new thread in the current OS process.

See also: Handling Messages

Constants

paragram.Any

Matches any object

paragram.etc

Matches any remaining objects in a tuple or list

paragram.main

A fake paragram process representing the main thread of control. This should not be directly referenced by anything but the main thread - if another process needs to talk to the main process, it should be sent a reference to this object in a message rather than accessing it directly.

Table Of Contents

Previous topic

Pattern Matching

This Page