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
-
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 fromTMUX_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
-
-
Socket
Path – When socket_path exceedsToo Long SOCKET_PATH_MAX_BYTESbytes.
-
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 callsThe 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.