1

I want to open a file descriptor and retrieve packets sent over a tun interface but:

packet = list(os.read(tun_fd.fileno(), 2048)) 

call is blocking, is there a way on how to have it non blocking. BTW I've found a flag os.O_NONBLOCK but that was I think only for os.open(file) command

NELOUNI
  • 593
  • 2
  • 6
  • 14
  • Hope this helps: http://stackoverflow.com/questions/375427/non-blocking-read-on-a-subprocess-pipe-in-python... You can probably use threading or multiprocessing.Process to run this in the background. – tomkaith13 Jun 03 '14 at 19:42
  • Consider the `select` call -- http://pymotw.com/2/select/ – johntellsall Jun 03 '14 at 20:28

0 Answers0