scripts: Increased default sleep time to 2 seconds
You forget one script, running in the background, hogging a whole core, and suddenly watch's default 2 second sleep time makes a lot more sense... One of the main motivators for watch.py _was_ for shorter sleep times, short enough to render realtime animations (watch is limited to 0.1 seconds for some reason?), but this doesn't mean it needs to be the default. This can still be accomplished by explicitly specifying -s/--sleep, and we probably don't want the default to hog all the CPU. The use case for fast sleeps has been mostly replaced by -k/--keep-open anyways. For tailpipe.py and tracebd.py it's a bit less clear, but we probably don't need to be spamming open calls 10 times a second.
This commit is contained in:
+3
-4
@@ -1445,11 +1445,10 @@ def main(csv_paths, *,
|
||||
ptime = time.time()
|
||||
inotify.read()
|
||||
inotify.close()
|
||||
# sleep for a minimum amount of time, this helps reduce
|
||||
# flicker issues
|
||||
# sleep a minimum amount of time to avoid flickering
|
||||
time.sleep(max(0, (sleep or 0.01) - (time.time()-ptime)))
|
||||
else:
|
||||
time.sleep(sleep or 0.1)
|
||||
time.sleep(sleep or 2)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
@@ -1669,7 +1668,7 @@ if __name__ == "__main__":
|
||||
'-s', '--sleep',
|
||||
type=float,
|
||||
help="Time in seconds to sleep between redraws when running "
|
||||
"with -k. Defaults to 0.01.")
|
||||
"with -k. Defaults to 2 seconds.")
|
||||
|
||||
def dictify(ns):
|
||||
if hasattr(ns, 'subplots'):
|
||||
|
||||
+3
-2
@@ -129,6 +129,7 @@ def main(path='-', *,
|
||||
event.clear()
|
||||
with lock:
|
||||
ring.draw()
|
||||
# sleep a minimum amount of time to avoid flickering
|
||||
time.sleep(sleep or 0.01)
|
||||
th.Thread(target=background, daemon=True).start()
|
||||
|
||||
@@ -143,7 +144,7 @@ def main(path='-', *,
|
||||
if not keep_open:
|
||||
break
|
||||
# don't just flood open calls
|
||||
time.sleep(sleep or 0.1)
|
||||
time.sleep(sleep or 2)
|
||||
except FileNotFoundError as e:
|
||||
print("error: file not found %r" % path,
|
||||
file=sys.stderr)
|
||||
@@ -182,7 +183,7 @@ if __name__ == "__main__":
|
||||
parser.add_argument(
|
||||
'-s', '--sleep',
|
||||
type=float,
|
||||
help="Seconds to sleep between reads. Defaults to 0.01.")
|
||||
help="Seconds to sleep between reads.")
|
||||
parser.add_argument(
|
||||
'-k', '--keep-open',
|
||||
action='store_true',
|
||||
|
||||
+2
-1
@@ -1020,6 +1020,7 @@ def main(path='-', *,
|
||||
draw(ring)
|
||||
if not cat:
|
||||
ring.draw()
|
||||
# sleep a minimum amount of time to avoid flickering
|
||||
time.sleep(sleep or 0.01)
|
||||
th.Thread(target=background, daemon=True).start()
|
||||
|
||||
@@ -1044,7 +1045,7 @@ def main(path='-', *,
|
||||
if not keep_open:
|
||||
break
|
||||
# don't just flood open calls
|
||||
time.sleep(sleep or 0.1)
|
||||
time.sleep(sleep or 2)
|
||||
except FileNotFoundError as e:
|
||||
print("error: file not found %r" % path,
|
||||
file=sys.stderr)
|
||||
|
||||
+3
-4
@@ -247,12 +247,11 @@ def main(command, *,
|
||||
ptime = time.time()
|
||||
inotify.read()
|
||||
inotify.close()
|
||||
# sleep for a minimum amount of time, this helps reduce
|
||||
# flicker issues
|
||||
# sleep a minimum amount of time to avoid flickering
|
||||
time.sleep(max(0, (sleep or 0.01) - (time.time()-ptime)))
|
||||
# or sleep
|
||||
else:
|
||||
time.sleep(sleep or 0.1)
|
||||
time.sleep(sleep or 2)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
@@ -291,7 +290,7 @@ if __name__ == "__main__":
|
||||
parser.add_argument(
|
||||
'-s', '--sleep',
|
||||
type=float,
|
||||
help="Seconds to sleep between runs. Defaults to 0.1.")
|
||||
help="Seconds to sleep between runs. Defaults to 2 seconds.")
|
||||
parser.add_argument(
|
||||
'-k', '--keep-open',
|
||||
action='store_true',
|
||||
|
||||
Reference in New Issue
Block a user