Ticket #14533: signal_ts.py

File signal_ts.py, 771 bytes (added by milosu, 14 years ago)
Line 
1import os, sys
2from threading import Thread
3from time import sleep, time
4
5os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
6
7from django.db.models import signals
8
9class SignalTester(Thread):
10 def __init__(self, id):
11 Thread.__init__(self)
12 self.id = id
13 def handler(self, **kwargs):
14 return
15 def handler2(self, **kwargs):
16 return
17 def run(self):
18 sleep(0.05)
19 signals.post_save.connect(self.handler, sender=None)
20 signals.post_delete.connect(self.handler2, sender=None)
21 sleep(0.05)
22 signals.post_save.disconnect(self.handler, sender=None)
23 signals.post_delete.disconnect(self.handler2, sender=None)
24 print 'thread %s done' % self.id
25
26threads = []
27i = 0
28while i < 100:
29 i += 1
30 t = SignalTester(i)
31 t.daemon = True
32 t.setDaemon(t.daemon)
33 t.start()
34
35sleep(2)
Back to Top