Ticket #9409: db_locked_error.py

File db_locked_error.py, 690 bytes (added by mrts, 16 years ago)
Line 
1#!/usr/bin/env python2.6
2
3import random
4from multiprocessing import Process as Worker
5
6from django.core.management import setup_environ
7from concurrent import settings
8setup_environ(settings)
9
10from concurrent.foo.models import Foo
11
12class ConcurrentAccess(Worker):
13 def __init__(self):
14 super(ConcurrentAccess, self).__init__()
15
16 def run(self):
17 f = Foo(bar=random.randint(0, 1000))
18 f.save()
19
20def launch_worker():
21 w = ConcurrentAccess()
22 w.start()
23 return w
24
25def main():
26 workers = []
27 for i in xrange(0, 100):
28 workers.append(launch_worker())
29 for w in workers:
30 w.join()
31 print("Done")
32
33if __name__ == '__main__':
34 main()
Back to Top