python Arquivo de leitura sem bloco
Eu quero ler um arquivo no modo sem bloqueio. Então eu gostei abaixo
import fcntl
import os
fd = open("./filename", "r")
flag = fcntl.fcntl(fd.fileno(), fcntl.F_GETFD)
fcntl.fcntl(fd, fcntl.F_SETFD, flag | os.O_NONBLOCK)
flag = fcntl.fcntl(fd, fcntl.F_GETFD)
if flag & os.O_NONBLOCK:
print "O_NONBLOCK!!"
Mas o valorflag
ainda representa 0. Por que ..? eu acho que deveria ser mudado de acordo comos.O_NONBLOCK
E, claro, se eu chamar fd.read (), ele será bloqueado em read ().