asynctnt.instance

Classes

TarantoolInstanceProtocol

Interface for protocol for subprocess calls.

TarantoolInstance

TarantoolSyncInstance

TarantoolAsyncInstance

TarantoolSyncDockerInstance

Module Contents

class asynctnt.instance.TarantoolInstanceProtocol(tnt, on_exit)[source]

Bases: asyncio.SubprocessProtocol

Interface for protocol for subprocess calls.

_tnt[source]
_on_exit[source]
_transport = None[source]
property logger[source]
property pid[source]
connection_made(transport)[source]

Called when a connection is made.

The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called.

pipe_data_received(fd, data)[source]

Called when the subprocess writes data into stdout/stderr pipe.

fd is int file descriptor. data is bytes object.

process_exited()[source]

Called when subprocess has exited.

property returncode[source]
async wait()[source]

Wait until the process exit and return the process return code.

This method is a coroutine.

send_signal(signal)[source]
terminate()[source]
kill()[source]
class asynctnt.instance.TarantoolInstance(*, host='127.0.0.1', port=3301, console_host=None, console_port=3302, replication_source=None, title=None, logger=None, log_level=5, slab_alloc_arena=0.1, wal_mode='none', root=None, specify_work_dir=True, cleanup=True, initlua_template=None, applua='-- app.lua --', extra_box_cfg='', timeout=5.0, command_to_run='tarantool', command_args=None)[source]
_host = '127.0.0.1'[source]
_port = 3301[source]
_console_host = '127.0.0.1'[source]
_console_port = 3302[source]
_replication_source = None[source]
_title[source]
_logger[source]
_log_level = 5[source]
_slab_alloc_arena = 0.1[source]
_wal_mode = 'none'[source]
_root[source]
_specify_work_dir = True[source]
_cleanup = True[source]
_initlua_template = Multiline-String[source]
Show Value
"""
            local function check_version(expected, version)
                -- from tarantool/queue compat.lua
                local fun = require 'fun'
                local iter, op  = fun.iter, fun.operator
                local function split(self, sep)
                    local sep, fields = sep or ":", {}
                    local pattern = string.format("([^%s]+)", sep)
                    self:gsub(pattern, function(c) table.insert(fields, c) end)
                    return fields
                end

                local function reducer(res, l, r)
                    if res ~= nil then
                        return res
                    end
                    if tonumber(l) == tonumber(r) then
                        return nil
                    end
                    return tonumber(l) > tonumber(r)
                end

                local function split_version(version_string)
                    local vtable  = split(version_string, '.')
                    local vtable2 = split(vtable[3],  '-')
                    vtable[3], vtable[4] = vtable2[1], vtable2[2]
                    return vtable
                end

                local function check_version_internal(expected, version)
                    version = version or _TARANTOOL
                    if type(version) == 'string' then
                        version = split_version(version)
                    end
                    local res = iter(version):zip(expected)
                                             :reduce(reducer, nil)
                    if res or res == nil then res = true end
                    return res
                end

                return check_version_internal(expected, version)
            end
            local cfg = {
              listen = "${host}:${port}",
              wal_mode = "${wal_mode}",
              custom_proc_title = "${custom_proc_title}",
              slab_alloc_arena = ${slab_alloc_arena},
              work_dir = ${work_dir},
              log_level = ${log_level},
              ${extra_box_cfg}
            }
            if check_version({1, 7}, _TARANTOOL) then
                cfg.replication = ${replication_source}
            else
                local repl = ${replication_source}
                if type(repl) == 'table' then
                    repl = table.concat(repl, ',')
                end
                cfg.replication_source = repl
            end
            require('console').listen("${console_host}:${console_port}")
            box.cfg(cfg)
            box.schema.user.grant("guest", "read,write,execute", "universe",
                                  nil, {if_not_exists = true})
            ${applua}
        """
_applua = '-- app.lua --'[source]
_extra_box_cfg = ''[source]
_command_to_run = 'tarantool'[source]
_command_args = None[source]
_timeout = 5.0[source]
_is_running = False[source]
property replication_source[source]
_random_string(length, *, source=string.ascii_uppercase + string.ascii_lowercase + string.digits)[source]
_generate_title()[source]
_generate_root_folder_name()[source]
static get_random_port()[source]
_create_initlua_template()[source]
_render_initlua()[source]
_save_initlua(initlua)[source]
property logger[source]
property fingerprint[source]
prepare(recreate)[source]
property host[source]
property port[source]
property console_port[source]
property is_running[source]
abstract property pid[source]
abstract command(cmd, print_greeting=True)[source]
abstract start(*, wait=True, recreate=True)[source]
abstract stop()[source]
abstract terminate()[source]
abstract kill()[source]
cleanup()[source]
class asynctnt.instance.TarantoolSyncInstance(**kwargs)[source]

Bases: TarantoolInstance

WAIT_TIMEOUT = 5[source]
_process = None[source]
_logger_thread = None[source]
__enter__()[source]
__exit__(exc_type, exc_val, exc_tb)[source]
property pid[source]
start(*, wait=True, recreate=True)[source]
_log_reader()[source]
stop()[source]
terminate()[source]
kill()[source]
_wait(timeout, wait=True)[source]
cleanup()[source]
static _parse_version(version: str) tuple | None[source]
version() tuple | None[source]
property bin_version: tuple | None[source]
command(cmd, print_greeting=True)[source]
class asynctnt.instance.TarantoolAsyncInstance(**kwargs)[source]

Bases: TarantoolInstance

_is_stopping = False[source]
_transport = None[source]
_protocol = None[source]
_last_return_code = None[source]
_stop_event[source]
property pid[source]
prepare(recreate)[source]
_on_process_exit(return_code)[source]
async wait_stopped()[source]
async version()[source]
async command(cmd, print_greeting=True)[source]
async start(*, wait=True, recreate=True)[source]
async stop()[source]
terminate()[source]
kill()[source]
cleanup()[source]
class asynctnt.instance.TarantoolSyncDockerInstance(*, docker_image=None, docker_tag=None, host='0.0.0.0', port=3301, console_host=None, console_port=3302, replication_source=None, title=None, logger=None, log_level=5, slab_alloc_arena=0.1, wal_mode='none', initlua_template=None, applua='-- app.lua --', timeout=10.0)[source]

Bases: TarantoolSyncInstance

_docker_image = 'tarantool/tarantool'[source]
_docker_tag = '1'[source]
_command_to_run[source]
_command_args[source]
property bin_version: tuple | None[source]