scripts: Changed -~/--sleep -> -w/--wait to sleep after -k/--keep-open
This changes -w/--wait to sleep _after_ -k/--keep-open, instead of including the time spent waiting on inotifywait in the sleep time. 1. It's easier, no need to keep track of when we started waiting. 2. It's simpler to reason about. 3. It trivially avoids the multiple wakeup noise that plagued watch.py + vim (vim likes to do a bunch of renaming and stuff when saving files, including the file 4913 randomly?) Avoiding this was previously impossible because -~/--sleep was effectively a noop when combined with -k/--keep-open. --- Also renamed from -~/--sleep -> -w/--wait, which is a bit more intuitive and avoids possible shell issues with -~. To make this work, dropped the -w/--block-cycles shortform flag in dbgtrace.py. It's not like this flag is ever used anyways. Though at the moment this is ignoring the possible conflict with -w/--word-bits...
This commit is contained in:
+4
-4
@@ -152,7 +152,7 @@ def main(path='-', *,
|
||||
lines=5,
|
||||
cat=False,
|
||||
coalesce=None,
|
||||
sleep=None,
|
||||
wait=None,
|
||||
keep_open=False):
|
||||
lock = th.Lock()
|
||||
event = th.Event()
|
||||
@@ -175,7 +175,7 @@ def main(path='-', *,
|
||||
if not keep_open:
|
||||
break
|
||||
# don't just flood open calls
|
||||
time.sleep(sleep or 2)
|
||||
time.sleep(wait or 2)
|
||||
|
||||
except FileNotFoundError as e:
|
||||
print("error: file not found %r" % path,
|
||||
@@ -200,7 +200,7 @@ def main(path='-', *,
|
||||
with lock:
|
||||
ring.draw()
|
||||
# sleep a minimum amount of time to avoid flickering
|
||||
time.sleep(sleep or 0.01)
|
||||
time.sleep(wait or 0.01)
|
||||
th.Thread(target=background, daemon=True).start()
|
||||
|
||||
main_(ring)
|
||||
@@ -240,7 +240,7 @@ if __name__ == "__main__":
|
||||
type=lambda x: int(x, 0),
|
||||
help="Number of lines to coalesce together.")
|
||||
parser.add_argument(
|
||||
'-~', '--sleep',
|
||||
'-w', '--wait',
|
||||
type=float,
|
||||
help="Seconds to sleep between draws, coalescing lines in "
|
||||
"between.")
|
||||
|
||||
Reference in New Issue
Block a user