don even ask about this shit import system signals __name__ system sig

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
### don't even ask about this shit
import system.signals
__name__='system.signals.test'
###
from threading import Timer
from entities import Group, Signal, Hook, Lock, MultiHandler, MultiHook
from engine import Processor
class IRC(Group):
class Connection(Group):
class Opened(Signal):
pass
class Closed(Signal):
pass
class Error(Signal):
pass
class Message(Group):
class Raw(Signal):
pass
class Parsed(Signal):
pass
IRC.initialize()
#@Hook(IRC.Connection.Opened, 2)
#def handler1(*args, **kwargs):
# print "Handled 1", args, kwargs
#
#@Hook(IRC.Connection.Opened, 1, intercept=True)
#def handler2(*args, **kwargs):
# print "Handled 2", args, kwargs
class Test(MultiHandler):
def __init__(self, sp):
self.sp = sp
sp.hooks.add(self.handler1__hook)
sp.hooks.add(self.handler2__hook)
@MultiHook(IRC.Connection.Opened, priority=2)
def handler1(self, *args, **kwargs):
print "Handled 1", self, args, kwargs
@MultiHook(IRC.Connection.Opened, priority=1, intercept=True)
def handler2(self, *args, **kwargs):
print "Handled 2", self, args, kwargs
lock = Lock(IRC.Connection.Opened)
sp = Processor()
#sp.hooks.add(handler1)
#sp.hooks.add(handler2)
#sp.hooks.remove(handler1)
#sp.hooks.remove(handler2)
test1 = Test(sp)
test2 = Test(sp)
sp.hooks.add(lock)
Timer(5, sp.broadcast, (IRC.Connection.Opened(1,2,3),)).start()
Timer(10, sp.broadcast, (IRC.Connection.Opened(1,2,3),)).start()
#print 'going to lock'
#lock.wait()
#print 'being released'
#print 'going to lock 2'
#lock.reset()
#lock.wait()
#print 'being released 2'