Skip to main content

Django Session Space Analysis Tool

This is a Django management command (as in https://docs.djangoproject.com/en/dev/howto/custom-management-commands/) that cleans up expired sessions from the database.

Why?

Django ships with a built-in command to handle session cleanup, but it is problematic when dealing with large session tables. Due to its design, it can block writes to the session table for minutes at a time, potentially disrupting sites that rely on sessions. This command is designed to perform the same maintenance tasks as the built-in command without disrupting a site by locking the table for a really long time.

Installation

Install the distribution from PyPI, e.g. pip install django-batch-session-cleanup.

Then, add batch_sesion_cleanup to INSTALLED_APPS in your Django project.

That’s it. You can now run django-admin.py and confirm that the command shows up.

Example Uses

Delete expired sessions in batches of no more than 50000, and sleep for 2 seconds in between batches::

django-admin.py batch-session-cleanup --batch-size=50000 --sleep-time=2

Known Issues and Bugs

  • The tool has only been tested thoroughly on a MyISAM MySQL table. I’m not aware of any reason that it wouldn’t work on other SQL session backends, but you should be careful if you’re using it in those environments.

Author

Kevan Carstensen <kevan@isnotajoke.com>

Metadata

Release files for django-batch-session-cleanup 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-batch-session-cleanup 0.1.1
File Size Uploaded Provenance
django-batch-session-cleanup-0.1.1.tar.gz 3.5 kB Without provenance Details

Release files / django-batch-session-cleanup-0.1.1.tar.gz

Download URL django-batch-session-cleanup-0.1.1.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f566fc06803d5f3cd11ee2a59fbca7df39737bb40ad01ac0320f7a5e14140847
BLAKE2b-256 checksum
How to use checksums
fb315e70068d769673457cd50c5465b77cdb5801559896447a5e1a323f162b38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-batch-session-cleanup 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page