[tahoe-lafs-trac-stream] [Tahoe-LAFS] #3512: Client.init_tempdir clobbers global state in an annoying way

Tahoe-LAFS trac at tahoe-lafs.org
Wed Nov 18 18:38:26 UTC 2020


#3512: Client.init_tempdir clobbers global state in an annoying way
---------------------+---------------------------
 Reporter:  exarkun  |          Owner:
     Type:  defect   |         Status:  new
 Priority:  normal   |      Milestone:  undecided
Component:  unknown  |        Version:  n/a
 Keywords:           |  Launchpad Bug:
---------------------+---------------------------
 {{{
     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.

--
Ticket URL: <https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3512>
Tahoe-LAFS <https://Tahoe-LAFS.org>
secure decentralized storage


More information about the tahoe-lafs-trac-stream mailing list