Skip to content

Instantly share code, notes, and snippets.

@Almenon
Created May 19, 2020 04:58
Show Gist options
  • Save Almenon/77a1f345e8d36b959ec9c055a3044d59 to your computer and use it in GitHub Desktop.
Save Almenon/77a1f345e8d36b959ec9c055a3044d59 to your computer and use it in GitHub Desktop.
node_buffer_issue_python_script
import sys
from time import sleep
# numBytes = 2 ** 29
# sys.stdout.write("a" * numBytes)
# only one flush
# sys.stdout.write("a")
# sys.stdout.flush()
# sleep(0.000000000000001)
# less than a picosecond, nonsense number. But the ~6ms it takes to invoke sleep and return is enough delay for node to process flush
# sys.stdout.write("aa")
# sys.stdout.flush()
# this block results in two flushes
# for i in range(8192 * 2 + 2):
# sys.stdout.write("a")
# 2 flushes
# for i in range(2):
# sys.stdout.write("a" * (8192 + 1))
# two flushes
# sys.stdout.write("a" * (8192 + 1))
# sys.stdout.write("a" * (8192 + 1))
# two flushes
sys.stdout.write("a" * (8192 * 2 + 2))
# one flush
sleep(3)
print("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment