Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

A small extension for the tempfile module.

Project description

Temporary files and directories.

Contains replacement for tempfile.NamedTemporaryFile that does not delete the file on close(), but still unlinks it after the context manager ends, as well as a mkdtemp-based temporary directory implementation.

  • Mostly reuses the stdlib implementations, supporting the same signatures.
  • Due to that, uses the OS’s built-in temporary file facilities, no custom schemes.
  • Tested on Python 2.6+ and 3.3+


A typical use-case that is not possible with the regular NamedTemporaryFile:

import volatile

with volatile.file() as tmp:
    # tmp behaves like a regular NamedTemporaryFile here, except for that
    # it gets unlinked at the end of the context manager, instead of when
    # close() is called.


    # run the users $EDITOR

    buf = open(

    # ...

Temporary directories:

import volatile

with volatile.dir(): as dtmp:
    pass  # ... can use directory here

# a missing dtmp will not throw an exception!

Unix domain sockets:

import volatile

with volatile.unix_socket(): as (sock, addr):
    # sock is the bound socket, addr its address on the filesystem
    pass  # ... can use directory here

The source is fairly short and contains API docs in the comments.

Project details

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
volatile-2.1.0.tar.gz (3.3 kB) Copy SHA256 hash SHA256 Source None Apr 4, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page