Async socket question

Ah, I believe what is happening is that you have two simultaneous calls to Reader.read, which is disallowed (see the module comment on Reader):

Each of the read functions returns a deferred that will become determined when the read completes. It is an error to have two simultaneous reads. That is, if you call a read function, you should not call another read function until the first one completes.

One suggestion would be to use the Pipe interface rather than directly using Reader. You can call Reader.lines or Reader.pipe and then use Pipe.read_choice to “try” to read from the socket (without actually consuming the data if the other input arrives first).

1 Like