[Python-Dev] RE: test_asynchat.py broken on Windows
Tim Peters
tim.one@home.com
Mon, 29 Oct 2001 20:37:49 -0500
[Jeremy Hylton]
> I think there are at least three things wrong, depending on what you
> count as wrong.
I would have guessed five, if you were counting Windows too <wink>.
> The test is hanging because it spawns a thread, which Python will
> prevent Python from exiting until the thread exits. The thread
> doesn't exit because it's waiting for input from the client. The
> client doesn't send it any input because of the exception.
>
> thing wrong #1: It would probably make sense to change
> test_asynchat.py to use a daemon thread so that it can't prevent the
> test suite from exiting.
I don't much care about this.
> thing wrong #2: I don't think the ENONET being returned by
> connect_ex() makes any sense. My guess is that connect_ex() is (and
> always has been) broken on Windows. Could you apply this patch and
> see what happens:
> ...
Fixed the problem, so I checked it in. Thanks!
> thing wrong #3: From the winsock documentation for connect(), it looks
> like there are more errors we should be catching in the test that
> includes EWOULDBLOCK and EALREADY. I don't think this would affect
> your test, though.
I'm not sure I parsed that as intended; asyncore.dispatcher.connect (in the
traceback when test_asynchat failed) is already checking for EINPROGRESS,
EALREADY, EWOULDBLOCK, 0 and EISCONN returns from connect_ex. But, for
posterity, I will inscribe my socket programming knowledge in the period at
the end of this sentence.
> thing wrong #4: It doesn't look to me like the connect() call in
> test_asynchat.py is guaranteed to succeed. It should succeed almost
> every time, but there's some small chance it will fail. Perhaps the
> test should be more robust about that.
FWIW, I've never seen it fail before.
> That's four things, but I don't think the last thing is all that wrong.
Here's a fifth:
def main():
s = echo_server()
s.start()
time.sleep(1) # Give server time to initialize
c = echo_client()
...
time.sleep()-is-not-a-synchronization-gimmick-ly y'rs - tim