# HG changeset patch
# User William Stein <wstein@gmail.com>
# Date 1277358107 25200
# Node ID 7523af317075c0a7b650c328e28eeb10f2cdcc9a
# Parent 1b1239c4c86ae3026c41d961d2775017ad681d88
trac 8410: Improve robustness of @parallel
diff -r 1b1239c4c86a -r 7523af317075 sage/parallel/use_fork.py
a
|
b
|
|
109 | 109 | os.kill(pid,9) |
110 | 110 | X[-1] = ' (timed out)' |
111 | 111 | else: |
112 | | # collect data from process that successfully terminated |
113 | | sobj = os.path.join(dir, '%s.sobj'%pid) |
114 | | if not os.path.exists(sobj): |
115 | | X = "NO DATA" + workers[pid][-1] # the message field |
116 | | else: |
117 | | X = load(sobj, compress=False) |
118 | | os.unlink(sobj) |
119 | | out = os.path.join(dir, '%s.out'%pid) |
120 | | if not os.path.exists(out): |
121 | | output = "NO OUTPUT" |
122 | | else: |
123 | | output = open(out).read() |
124 | | os.unlink(out) |
| 112 | # If the computation was interrupted the pid |
| 113 | # might not be in the workers list, in which |
| 114 | # case we skip this. |
| 115 | if pid in workers: |
| 116 | # collect data from process that successfully terminated |
| 117 | sobj = os.path.join(dir, '%s.sobj'%pid) |
| 118 | if not os.path.exists(sobj): |
| 119 | X = "NO DATA" + workers[pid][-1] # the message field |
| 120 | else: |
| 121 | X = load(sobj, compress=False) |
| 122 | os.unlink(sobj) |
| 123 | out = os.path.join(dir, '%s.out'%pid) |
| 124 | if not os.path.exists(out): |
| 125 | output = "NO OUTPUT" |
| 126 | else: |
| 127 | output = open(out).read() |
| 128 | os.unlink(out) |
125 | 129 | |
126 | | if output.strip(): |
127 | | print output, |
| 130 | if output.strip(): |
| 131 | print output, |
128 | 132 | |
129 | | yield (workers[pid][0], X) |
130 | | del workers[pid] |
| 133 | yield (workers[pid][0], X) |
| 134 | del workers[pid] |
131 | 135 | |
132 | 136 | except Exception, msg: |
133 | 137 | print msg |