Fixed a race between setTarget and flush in logging.handlers.MemoryHandler.