我有一个处理登录的python cgi脚本,这是因为我的网站是三个(学校)网站的组合,在我的网站可以使用之前,需要从这些网站中提取数据.这个提取需要2分钟,所以我想制作一个花哨的(半假的)加载屏幕.
我的注册码以:
import subprocess
token = "".join(random.choice(
string.ascii_lowercase + string.digits + string.ascii_uppercase)
for _ in range(5)) #generate 5 random characters
#run initScript
subprocess.Popen("python {}/python/initUser.py {} {}".format(
os.getcwd(), uid,token), shell=True, stdin=None, stdout=None, stderr=None,
close_fds=True)
print "Content-type: text/html"
print "Location: registerLoading.php?token={}".format(token)
print
sys.exit(0)
Run Code Online (Sandbox Code Playgroud)
但是子流程线仍在阻塞,我无法弄清楚原因.
我正在开发ubuntu 16.04,它将在raspbarry pi 3上运行(这解释了加载时间)
我想尝试基本的文件加密和压缩,所以我的第一个问题是 ByteReader 是否适合这项工作?我的第二个最重要的问题是:使用二进制读取器时如何循环到文件末尾?有没有办法像 StreamReader 一样做到这一点,如How read a file into a seq of lines in F# 中所述?
我想做以下事情:
let reader = new BinaryReader(File.Open("anyFile",FileMode.Open,FileAccess.Read)
let mutable data = []
while -condition i can't find- do
data <- [reader.readBytes()] :: data
//do fancy things with the achieved data
Run Code Online (Sandbox Code Playgroud)