-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_pyx.pyx
73 lines (58 loc) · 1.44 KB
/
test_pyx.pyx
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
import ev
cimport ev
from test_py import pipe
cdef class TestSubclassing(ev.Timer):
"""
>>> t = TestSubclassing()
>>> t.is_active()
True
>>> ev.main()
>>> t.timedout
True
>>> t.is_active()
False
"""
cdef public bint timedout
def __init__(self):
ev.Timer.__init__(self, .001)
self.timedout = False
self.start()
cdef event_handler(self, int revents):
self.timedout = True
ev.quit()
cdef class TestCCallback(ev.Timer):
"""
>>> t = TestCCallback()
>>> t.is_active()
True
>>> ev.main()
>>> t.timedout
True
>>> t.is_active()
False
"""
cdef public bint timedout
def __init__(self):
ev.Timer.__init__(self, .001)
self.timedout = False
self.set_ccallback(<ev.watcher_cb>self.ccallback,
<void *> self)
self.start()
cdef void ccallback(self, ev.IO io, int event) except *:
self.timedout = True
ev.quit()
cdef class TestCCallbackExc(ev.Timer):
"""
>>> t = TestCCallbackExc()
>>> ev.main()
Traceback (most recent call last):
...
Error: oops
"""
def __init__(self):
ev.Timer.__init__(self, .001)
self.set_ccallback(<ev.watcher_cb>self.ccallback,
<void *> self)
self.start()
cdef void ccallback(self, ev.IO io, int event) except *:
raise ev.Error, "oops"