1 |
Author: zmedico |
2 |
Date: 2009-09-27 19:45:09 +0000 (Sun, 27 Sep 2009) |
3 |
New Revision: 14449 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/__init__.py |
7 |
Log: |
8 |
Make _test_pty_eof() use non-blocking IO, required for Darwin kernel. |
9 |
|
10 |
|
11 |
Modified: main/trunk/pym/portage/__init__.py |
12 |
=================================================================== |
13 |
--- main/trunk/pym/portage/__init__.py 2009-09-27 19:07:57 UTC (rev 14448) |
14 |
+++ main/trunk/pym/portage/__init__.py 2009-09-27 19:45:09 UTC (rev 14449) |
15 |
@@ -3746,7 +3746,7 @@ |
16 |
Raises an EnvironmentError from openpty() if it fails. |
17 |
""" |
18 |
|
19 |
- import array, pty, termios |
20 |
+ import array, fcntl, pty, select, termios |
21 |
test_string = 2 * "blah blah blah\n" |
22 |
test_string = _unicode_decode(test_string, |
23 |
encoding='utf_8', errors='strict') |
24 |
@@ -3757,6 +3757,10 @@ |
25 |
master_file = os.fdopen(master_fd, 'rb') |
26 |
slave_file = os.fdopen(slave_fd, 'wb') |
27 |
|
28 |
+ # Non-blocking mode is required for Darwin kernel. |
29 |
+ fcntl.fcntl(master_fd, fcntl.F_SETFL, |
30 |
+ fcntl.fcntl(master_fd, fcntl.F_GETFL) | os.O_NONBLOCK) |
31 |
+ |
32 |
# Disable post-processing of output since otherwise weird |
33 |
# things like \n -> \r\n transformations may occur. |
34 |
mode = termios.tcgetattr(slave_fd) |
35 |
@@ -3771,9 +3775,17 @@ |
36 |
|
37 |
eof = False |
38 |
data = [] |
39 |
+ iwtd = [master_file] |
40 |
+ owtd = [] |
41 |
+ ewtd = [] |
42 |
|
43 |
while not eof: |
44 |
|
45 |
+ events = select.select(iwtd, owtd, ewtd) |
46 |
+ if not events[0]: |
47 |
+ eof = True |
48 |
+ break |
49 |
+ |
50 |
buf = array.array('B') |
51 |
try: |
52 |
buf.fromfile(master_file, 1024) |