Skip to content

Commit

Permalink
Merge pull request #1914 from locustio/auto-resize-stats-table-on-ter…
Browse files Browse the repository at this point in the history
…minal-window-resize

Auto-resize stats table when terminal window is resized
  • Loading branch information
cyberw authored Oct 26, 2021
2 parents ec95c0d + 7ad87d4 commit 1ffe8c3
Showing 1 changed file with 13 additions and 1 deletion.
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

0 comments on commit 1ffe8c3

Please sign in to comment.