-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.py
More file actions
38 lines (29 loc) · 861 Bytes
/
Copy pathcore.py
File metadata and controls
38 lines (29 loc) · 861 Bytes
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
import os
import signal
import errno
def asyncloop(g):
def h_sigchld(sig, frm):
while True:
try:
pid, exitcode, res = os.wait3(os.WNOHANG)
if not pid:
break
g['pids'][pid].proc_finish(exitcode, res)
except OSError, E:
if E.errno == errno.ECHILD:
break
else:
raise
signal.signal(signal.SIGCHLD, h_sigchld)
while True:
try:
for ready in g['poller'].poll():
print ready
fd, event = ready
try: g['fds'][fd].handle_event(fd, event)
except KeyError: continue
except IOError, e:
if e.errno == errno.EINTR:
continue
else:
raise