use 1 transaction for the whole faults command db update
hopefully this is much faster than the default behaviour which does 1 transaction per save(), so the database is not locked such a long time.
This commit is contained in:
parent
3cf5e6ff96
commit
cafaeeb64e
@ -5,6 +5,7 @@ dealing with the fault counters and available/abuse/abuse_blocked flags
|
|||||||
from optparse import make_option
|
from optparse import make_option
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
from django.db import transaction
|
||||||
|
|
||||||
from nsupdate.main.models import Host
|
from nsupdate.main.models import Host
|
||||||
|
|
||||||
@ -73,6 +74,7 @@ class Command(BaseCommand):
|
|||||||
reset_abuse = options['reset_abuse']
|
reset_abuse = options['reset_abuse']
|
||||||
reset_abuse_blocked = options['reset_abuse_blocked']
|
reset_abuse_blocked = options['reset_abuse_blocked']
|
||||||
flag_abuse = options['flag_abuse']
|
flag_abuse = options['flag_abuse']
|
||||||
|
with transaction.commit_on_success(): # TODO: after requiring django 1.6, use atomic()
|
||||||
for h in Host.objects.all():
|
for h in Host.objects.all():
|
||||||
if show_client or show_server:
|
if show_client or show_server:
|
||||||
output = u""
|
output = u""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user