﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	launchpad_bug
3512	Client.init_tempdir clobbers global state in an annoying way	exarkun	GitHub <noreply@…>	"{{{
    def init_tempdir(self):
        """"""
        Initialize/create a directory for temporary files.
        """"""
        tempdir_config = self.config.get_config(""node"", ""tempdir"", ""tmp"")
        if isinstance(tempdir_config, bytes):
            tempdir_config = tempdir_config.decode('utf-8')
        tempdir = self.config.get_config_path(tempdir_config)
        if not os.path.exists(tempdir):
            fileutil.make_dirs(tempdir)
        tempfile.tempdir = tempdir
}}}

This makes it impossible to have two `Client` instances in one process that are truly independent of each other.  The last one to init will make all the rest share its temporary directory!

In the past this has caused a lot of problem for the test suite when the mutation doesn't get cleaned up.  Some parts of the test suite nest more and more deeply into node temp dirs.  Sometimes this blows up the OS path length limits.  Other times it's just confusing.  Most recently for ticket:2916 one test leaked a *unicode* value into `tempfile.tempdir` and broke some subsequent tests which suddenly got unicode temp directories instead of bytes temp directories.

The explanatory comment:

{{{
        # this should cause twisted.web.http (which uses
        # tempfile.TemporaryFile) to put large request bodies in the given
        # directory. Without this, the default temp dir is usually /tmp/,
        # which is frequently too small.
}}}

makes it seem as though this is *only* for Twisted Web intermediate files.  We can fix these in a better way.  `Request.gotLength` and `Site.getContentFile` both give us interfaces to control this behavior in a way that's localized to a single client.

"	defect	closed	normal	undecided	unknown	n/a	fixed			
