todo comment
wait for IO to be ready for write (attempts to fix occasional "Bad file descriptor" error