Opened 8 years ago

Closed 8 years ago

#27690 closed Cleanup/optimization (fixed)

remove sleep before dropping test db?

Reported by: David Szotten Owned by: nobody
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Russell Keith-Magee Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Whilst looking at why a test run (with a small number of tests) was being slow, i discovered https://github.com/django/django/blob/master/django/db/backends/base/creation.py#L281

which calls sleep(1) before dropping the (test) db " to avoid "database is being accessed by other users" errors.".

it looks like this line has been there since the beginning of the test framework: https://github.com/django/django/commit/7dce86ce0220ffb9f3f579cbd1e881e988764c9d

is this still needed? the few things i've tried seem to work fine without the sleep, but i'm not sure what other tests/checks might help make sure

Change History (6)

comment:1 by Tim Graham, 8 years ago

Cc: Russell Keith-Magee added
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

That error message looks like PostgreSQL. I'll add Russ to Cc to see if he remembers anything about that, but I think it's worth removing it and seeing if anyone bug reports pop up. Database teardown is so much faster without it!

comment:2 by Tim Graham, 8 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

PR (will wait for any feedback before merging but I also haven't seen problems in my own testing)

comment:3 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: newclosed

In 7a6863c:

Fixed #27690 -- Removed time.sleep(1) before dropping the test database.

Uncertain if this is needed, but no failures have appeared so far.

comment:4 by Mariusz Felisiak, 8 years ago

Resolution: fixed
Status: closednew
Triage Stage: Ready for checkinAccepted

I prepared the same change for the Oracle backend.
PR

comment:5 by Tim Graham <timograham@…>, 8 years ago

In 7d2db2a:

Refs #27690 -- Removed sleep before drop test db on Oracle.

comment:6 by Tim Graham, 8 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top