Core Library0.xAPI reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

MoreLess about this notice

function libtmux

check_socket_path_length

Raise if socket_path is too long to be a UNIX socket address.

Source and package
Qualified name
libtmux._internal.env.check_socket_path_length
Module
libtmux._internal.env
Package
libtmux
Source
src/libtmux/_internal/env.py
check_socket_path_length ( socket_path: StrPath, socket_name: str | None = None, env_var: str | None = None, env_value: str | None = None, ) → None

Description

A tmux socket is a UNIX domain socket, so its path has to fit in SOCKET_PATH_MAX_BYTES -- a filesystem that accepts the path says nothing about whether a socket can be bound at it. Length is counted in bytes, as the kernel counts it, so a non-ASCII path runs out sooner than its character count suggests.

Parameters
  • socket_path (StrPath) – Path to measure.

  • socket_name (str | None) – Socket name socket_path was resolved from, when it was resolved rather than passed in. Recorded on the exception so the message can say the length was inherited from TMUX_TMPDIR.

    Default None

  • env_var (str | None) – Environment variable the socket directory came from, when one did. Recorded on the exception so the message can name it.

    Default None

  • env_value (str | None) – What that variable held, so the caller can see what to shorten.

    Default None

Raises

Examples

>>> from libtmux._internal.env import (
... check_socket_path_length,
... SOCKET_PATH_MAX_BYTES,
... )
>>> check_socket_path_length("/tmp/tmux-1000/default")
>>> try:
... check_socket_path_length("/tmp/" + "d" * 200 + "/sock")
... except exc.SocketPathTooLong as e:
... (e.length, e.limit == SOCKET_PATH_MAX_BYTES)
(210, True)

A name that resolves somewhere too deep reports the name too. The path is measured as given -- whether tmux would really bind there is settled by resolve_socket_path() before this is called:

>>> deep = pathlib.Path("/tmp/" + "d" * 200) / "tmux-1000" / "dev"
>>> try:
... check_socket_path_length(deep, socket_name="dev")
... except exc.SocketPathTooLong as e:
... e.socket_name
'dev'

Recorded calls

source calls
No call edges in the Python model.

The Python reference records declarations, not calls, so this page shows no callers or callees. That is a limit of the extracted data, not a statement that nothing calls libtmux._internal.env.check_socket_path_length.

Esc
Search in

Type to search.

Reference previewOpen reference