asyncore.file_dispatcher stores the file descriptor passed to asyncore.file_dispatcher.__init__ into the map, not the dup()'ed one created by asyncore.file_wrapper. Because of this, a "select.error (9, 'Bad file descriptor')" is raised in asyncore.loop() if the fd passed to asyncore.file_dispatcher.__init__ is closed while the loop is running. Attached patch fixes the issue.