allow a cllback in streamer

This commit is contained in:
mdipierro
2016-08-16 19:12:47 -05:00
parent 6e9c8212e2
commit e87378b07f
4 changed files with 25 additions and 22 deletions
+2 -2
View File
@@ -312,8 +312,8 @@ a:not(.btn):not(.noeffect):after {
/*** accordion ***/
.accordion>label{cursor:pointer}
.accordion>input ~ label:before {content:""; color:#ddd}
.accordion>input:checked ~ label:before {content:""; color:#ddd}
.accordion>input ~ label:before {content:"\25b2"; color:#ddd}
.accordion>input:checked ~ label:before {content:"\25bc"; color:#ddd}
.accordion>input {display:none}
.accordion>input:checked ~ *:not(label) {
max-height: 1000px !important;
+19 -16
View File
@@ -25,22 +25,25 @@ regex_stop_range = re.compile('(?<=\-)\d+')
DEFAULT_CHUNK_SIZE = 64 * 1024
def streamer(stream, chunk_size=DEFAULT_CHUNK_SIZE, bytes=None):
offset = 0
while bytes is None or offset < bytes:
if not bytes is None and bytes - offset < chunk_size:
chunk_size = bytes - offset
data = stream.read(chunk_size)
length = len(data)
if not length:
break
else:
yield data
if length < chunk_size:
break
offset += length
stream.close()
def streamer(stream, chunk_size=DEFAULT_CHUNK_SIZE, bytes=None, callback=None):
try:
offset = 0
while bytes is None or offset < bytes:
if not bytes is None and bytes - offset < chunk_size:
chunk_size = bytes - offset
data = stream.read(chunk_size)
length = len(data)
if not length:
break
else:
yield data
if length < chunk_size:
break
offset += length
finally:
stream.close()
if callback:
callback()
def stream_file_or_304_or_206(
static_file,
+3 -3
View File
@@ -214,18 +214,18 @@ then
fi
/etc/init.d/nginx start
start uwsgi-emperor
systemctl start emperor.uwsgi.service
echo <<EOF
you can stop uwsgi and nginx with
sudo /etc/init.d/nginx stop
sudo stop uwsgi-emperor
sudo systemctl start emperor.uwsgi.service
and start it with
sudo /etc/init.d/nginx start
sudo start uwsgi-emperor
systemctl start emperor.uwsgi.service
EOF