def stop(self, join = False, timeout = None):
logger.debug("<STR_LIT>")<EOL>for handler in self.io_handlers:<EOL><INDENT>handler.close()<EOL><DEDENT>if self.event_thread and self.event_thread.is_alive():<EOL><INDENT>logger.debug("<STR_LIT>")<EOL>self.event_queue.put(QUIT)<EOL><DEDENT>logger.debug("<STR_LIT>")<EOL>threads = self.io_threads + self.timeout_threads<EOL>for thread in threads:<EOL><INDENT>logger.debug("<STR_LIT>".format(thread))<EOL>thread.stop()<EOL><DEDENT>if not join:<EOL><INDENT>return<EOL><DEDENT>if self.event_thread:<EOL><INDENT>threads.append(self.event_thread)<EOL><DEDENT>if timeout is None:<EOL><INDENT>for thread in threads:<EOL><INDENT>thread.join()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>timeout1 = (timeout * <NUM_LIT>) / len(threads)<EOL>threads_left = []<EOL>for thread in threads:<EOL><INDENT>logger.debug("<STR_LIT>".format(thread))<EOL>thread.join(timeout1)<EOL>if thread.is_alive():<EOL><INDENT>logger.debug("<STR_LIT>".format(thread))<EOL>threads_left.append(thread)<EOL><DEDENT><DEDENT>if threads_left:<EOL><INDENT>timeout2 = (timeout * <NUM_LIT>) / len(threads_left)<EOL>for thread in threads_left:<EOL><INDENT>logger.debug("<STR_LIT>".format(thread))<EOL>thread.join(timeout2)<EOL><DEDENT><DEDENT><DEDENT>self.io_threads = []<EOL>self.event_thread = None<EOL>
Stop the threads.

        :Parameters:
            - `join`: join the threads (wait until they exit)
            - `timeout`: maximum time (in seconds) to wait when `join` is
              `True`).  No limit when `timeout` is `None`.