Inspirel banner

Programming Distributed Systems with YAMI4

4.3.26 Python

Creating an agent object in Python with 5 dispatcher threads instead of default one can be achieved with the following code:

import yami
# ...

options = { yami.Agent.OptionNames.DISPATCHER_THREADS:5 }

my_agent = yami.Agent(options)
# ...

The Agent.OptionNames class defines convenient string constants for all available configuration options.

Any subset of options can be used in a single parameters (or dictionary) object and those options which are not provided are considered to have their default values.

No parameters (or dictionary) object needs to be provided if all-default setup is intended, as shown in the following example:

from yami import Agent
# ...

my_agent = Agent()
# ...

Agents should be properly closed, which is achieved with the close() method call. This call is done automatically in Python 3.x if the agent object is used within the context manager:

with Agent() as agent:
    # ...