Skip to content

Commit

Permalink
[status-] decrease latency of status() when other threads run
Browse files Browse the repository at this point in the history
See https://stackoverflow.com/a/17407257
Inspect is slow to look up context lines, so it's a bit faster
to use context=0. When other busy threads run, context=1 can
have high latency, more than 100ms. In that situation, context=0
causes much less latency.
  • Loading branch information
midichef committed Apr 4, 2024
1 parent 581cdf1 commit 743c152
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion visidata/features/status_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@VisiData.api
def getStatusSource(vd):
stack = inspect.stack()
stack = inspect.stack(context=0) #2370
for i, sf in enumerate(stack):
if sf.function in 'status aside'.split():
if stack[i+1].function in 'error fail warning debug'.split():
Expand Down

0 comments on commit 743c152

Please sign in to comment.