Fix a race condition in the SMTP test of test_logging. Don't close a
file descriptor (socket) from a different thread while
asyncore.loop() is polling the file descriptor.
(cherry picked from commit 75ec103)
(cherry picked from commit e1903e1)
https://bugs.python.org/issue43842