juju.utils

Summary

IdQueue

Wrapper around asyncio.Queue that maintains a separate queue for each ID.

Methods:

execute_process
Wrapper around asyncio.create_subprocess_exec.
read_ssh_key
Attempt to read the local juju admin’s public ssh key, so that it can be passed on to a model.
run_with_interrupt
Awaits a task while allowing it to be interrupted by an asyncio.Event.

Reference

class juju.utils.IdQueue(maxsize=0, *, loop=None)[source]

Bases: object

Wrapper around asyncio.Queue that maintains a separate queue for each ID.

coroutine get(id)[source]
coroutine put(id, value)[source]
coroutine put_all(value)[source]
coroutine juju.utils.execute_process(*cmd, log=None, loop=None)[source]

Wrapper around asyncio.create_subprocess_exec.

coroutine juju.utils.read_ssh_key(loop)[source]

Attempt to read the local juju admin’s public ssh key, so that it can be passed on to a model.

coroutine juju.utils.run_with_interrupt(task, event, loop=None)[source]

Awaits a task while allowing it to be interrupted by an asyncio.Event.

If the task finishes without the event becoming set, the results of the task will be returned. If the event becomes set, the task will be cancelled None will be returned.

Parameters:
  • task – Task to run
  • event – An asyncio.Event which, if set, will interrupt task and cause it to be cancelled.
  • loop – Optional event loop to use other than the default.