Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import random
- import threading
- from django.db import connection, models, transaction
- from django.contrib.auth.models import User
- from useradmin.models import install_sample_user
- from desktop.models import Document, DocumentTag
- import beeswax.management.commands.beeswax_install_examples
- def run_thread(user, i):
- with transaction.atomic():
- for doc in Document.objects.filter(tags__tag=DocumentTag.EXAMPLE):
- default_tag = DocumentTag.objects.get_default_tag(doc.owner)
- doc.tags.remove(default_tag)
- def run():
- user, _ = User.objects.get_or_create(
- username='admin',
- password='admin',
- is_active=True,
- is_superuser=True)
- threads = []
- for i in xrange(2):
- thread = threading.Thread(target=run_thread, args=(user, i))
- threads.append(thread)
- for thread in threads:
- thread.start()
- for thread in threads:
- thread.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement