Created
January 16, 2015 13:23
-
-
Save igilham/0e070b6e11258a717154 to your computer and use it in GitHub Desktop.
An untested experimental program to stream files one packet at a time, with a pause feature. This will certainly be very slow if it works at all.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/env python | |
import signal | |
import sys | |
packet_size = 188 | |
position = 0 | |
paused = False | |
def pause_handler(signal, frame): | |
paused = not paused | |
signal.signal(signal.SIGINT, pause_handler) | |
infile = sys.stdin.buffer | |
outfile = sys.stdout.buffer | |
data = infile.read(packet_size) | |
position += 1 | |
while data: | |
if paused: | |
signal.pause() # sleep until any signal is received | |
outfile.write(data) | |
data = infile.read(packet_size) | |
position += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment