|
6 | 6 | "touch /tmp/hi" |
7 | 7 | run this script |
8 | 8 | run a few more times "touch /tmp/hi" |
9 | | -
|
10 | 9 | ''' |
11 | 10 |
|
12 | 11 | import os, sys, time, ctypes |
13 | 12 | import libev as ev |
14 | | - |
15 | 13 | print('libev version: %s.%s' %(ev.version_major(), ev.version_minor())) |
16 | 14 |
|
17 | | -main = ev.default_loop( 2 ) # ev.EVBACKEND_POLL = 2 |
18 | | -print(main) |
19 | | - |
20 | | -def ev_init(watcher, callback): |
21 | | - watcher.active = 0 |
22 | | - watcher.pending = 0 |
23 | | - cb = ev.ev_watcher._fields_[-1][-1]( callback ) |
24 | | - watcher.cb = cb |
25 | | - |
26 | | -def ev_stat_init( watcher, callback, path, interval=0.0 ): |
27 | | - ev_init( watcher, callback ) |
28 | | - watcher.path = path |
29 | | - watcher.interval = interval |
| 15 | +assert ev.EVBACKEND_POLL == 2 |
| 16 | +main = ev.default_loop( ev.EVBACKEND_POLL ) |
30 | 17 |
|
31 | 18 | watcher = ev.ev_stat() |
32 | 19 | def mycallback( loop, watcher, revents ): |
33 | 20 | print(loop, watcher, revents) |
34 | 21 |
|
35 | | -ev_init( watcher, mycallback ) |
36 | | -ev_stat_init( watcher, mycallback, '/tmp/hi' ) |
| 22 | +ev.init( watcher, mycallback ) |
| 23 | +ev.stat_init( watcher, mycallback, '/tmp/hi' ) |
37 | 24 | ptr = ctypes.pointer( watcher ) |
38 | 25 | ev.stat_start( main, ptr ) |
39 | 26 |
|
|
0 commit comments