Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-resize stats table when terminal window is resized #1914

Merged
merged 1 commit into from
Oct 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from itertools import chain
import os
import csv

import signal
import gevent

from .exception import StopUser, CatchResponseError
Expand All @@ -20,6 +20,18 @@
STATS_NAME_WIDTH = max(min(os.get_terminal_size()[0] - 80, 80), 0)
except OSError: # not a real terminal
STATS_NAME_WIDTH = 80

STATS_AUTORESIZE = True # overwrite this if you dont want auto resize while running


def resize_handler(signum, frame):
global STATS_NAME_WIDTH
if STATS_AUTORESIZE:
STATS_NAME_WIDTH = max(min(os.get_terminal_size()[0] - 80, 80), 0)


signal.signal(signal.SIGWINCH, resize_handler)

STATS_TYPE_WIDTH = 8

"""Default interval for how frequently results are written to console."""
Expand Down