|
55 | 55 | "source": [
|
56 | 56 | "Now, we can create a job manager (called simply `jobs`) and use it to submit new jobs.\n",
|
57 | 57 | "\n",
|
58 |
| - "Run the cell below, it will show when the jobs start and you can keep working:" |
| 58 | + "Run the cell below, it will show when the jobs start. Wait a few seconds until you see the 'all done' completion message:" |
59 | 59 | ]
|
60 | 60 | },
|
61 | 61 | {
|
|
67 | 67 | "# Start a few jobs, the first one will have ID # 0\n",
|
68 | 68 | "jobs.new(sleepfunc, 4)\n",
|
69 | 69 | "jobs.new(sleepfunc, kw={'reps':2})\n",
|
70 |
| - "jobs.new('printfunc(1,3)')\n", |
71 |
| - "\n", |
72 |
| - "# This makes a couple of jobs which will die. Let's keep a reference to\n", |
73 |
| - "# them for easier traceback reporting later\n", |
74 |
| - "diejob1 = jobs.new(diefunc, 1)\n", |
75 |
| - "diejob2 = jobs.new(diefunc, 2)" |
| 70 | + "jobs.new('printfunc(1,3)')" |
76 | 71 | ],
|
77 | 72 | "language": "python",
|
78 | 73 | "metadata": {},
|
|
83 | 78 | "text": [
|
84 | 79 | "Starting job # 0 in a separate thread.\n",
|
85 | 80 | "Starting job # 2 in a separate thread.\n",
|
86 |
| - "Starting job # 3 in a separate thread.\n", |
87 |
| - "Starting job # 4 in a separate thread.\n", |
88 |
| - "Starting job # 5 in a separate thread.\n" |
| 81 | + "Starting job # 3 in a separate thread.\n" |
| 82 | + ] |
| 83 | + }, |
| 84 | + { |
| 85 | + "output_type": "pyout", |
| 86 | + "prompt_number": 10, |
| 87 | + "text": [ |
| 88 | + "<BackgroundJob #3: printfunc(1,3)>" |
| 89 | + ] |
| 90 | + }, |
| 91 | + { |
| 92 | + "output_type": "stream", |
| 93 | + "stream": "stdout", |
| 94 | + "text": [ |
| 95 | + "In the background... 0\n" |
| 96 | + ] |
| 97 | + }, |
| 98 | + { |
| 99 | + "output_type": "stream", |
| 100 | + "stream": "stdout", |
| 101 | + "text": [ |
| 102 | + "In the background... 1\n" |
| 103 | + ] |
| 104 | + }, |
| 105 | + { |
| 106 | + "output_type": "stream", |
| 107 | + "stream": "stdout", |
| 108 | + "text": [ |
| 109 | + "In the background... 2\n" |
| 110 | + ] |
| 111 | + }, |
| 112 | + { |
| 113 | + "output_type": "stream", |
| 114 | + "stream": "stdout", |
| 115 | + "text": [ |
| 116 | + "All done!\n" |
89 | 117 | ]
|
90 | 118 | }
|
91 | 119 | ],
|
92 |
| - "prompt_number": 7 |
| 120 | + "prompt_number": 10 |
93 | 121 | },
|
94 | 122 | {
|
95 | 123 | "cell_type": "markdown",
|
|
111 | 139 | "output_type": "stream",
|
112 | 140 | "stream": "stdout",
|
113 | 141 | "text": [
|
114 |
| - "In the background... 0\n", |
115 |
| - "In the background... 1\n", |
116 |
| - "In the background... 2\n", |
117 |
| - "All done!\n", |
118 |
| - "Completed jobs:" |
119 |
| - ] |
120 |
| - }, |
121 |
| - { |
122 |
| - "output_type": "stream", |
123 |
| - "stream": "stdout", |
124 |
| - "text": [ |
125 |
| - "\n", |
126 |
| - "0 : <function sleepfunc at 0x2ef9230>\n", |
127 |
| - "2 : <function sleepfunc at 0x2ef9230>\n", |
| 142 | + "Completed jobs:\n", |
| 143 | + "0 : <function sleepfunc at 0x314f848>\n", |
| 144 | + "2 : <function sleepfunc at 0x314f848>\n", |
128 | 145 | "3 : printfunc(1,3)\n",
|
129 |
| - "\n", |
130 |
| - "Dead jobs:\n", |
131 |
| - "4 : <function diefunc at 0x2ef91b8>\n", |
132 |
| - "5 : <function diefunc at 0x2ef91b8>\n", |
133 | 146 | "\n"
|
134 | 147 | ]
|
135 | 148 | }
|
136 | 149 | ],
|
137 |
| - "prompt_number": 9 |
| 150 | + "prompt_number": 11 |
138 | 151 | },
|
139 | 152 | {
|
140 | 153 | "cell_type": "markdown",
|
|
153 | 166 | "metadata": {},
|
154 | 167 | "outputs": [
|
155 | 168 | {
|
156 |
| - "metadata": {}, |
157 | 169 | "output_type": "pyout",
|
158 |
| - "prompt_number": 13, |
| 170 | + "prompt_number": 12, |
159 | 171 | "text": [
|
160 | 172 | "{'args': (), 'interval': 4, 'kwargs': {}}"
|
161 | 173 | ]
|
162 | 174 | }
|
163 | 175 | ],
|
| 176 | + "prompt_number": 12 |
| 177 | + }, |
| 178 | + { |
| 179 | + "cell_type": "heading", |
| 180 | + "level": 2, |
| 181 | + "metadata": {}, |
| 182 | + "source": [ |
| 183 | + "Errors and tracebacks" |
| 184 | + ] |
| 185 | + }, |
| 186 | + { |
| 187 | + "cell_type": "markdown", |
| 188 | + "metadata": {}, |
| 189 | + "source": [ |
| 190 | + "The jobs manager tries to help you with debugging:" |
| 191 | + ] |
| 192 | + }, |
| 193 | + { |
| 194 | + "cell_type": "code", |
| 195 | + "collapsed": false, |
| 196 | + "input": [ |
| 197 | + "# This makes a couple of jobs which will die. Let's keep a reference to\n", |
| 198 | + "# them for easier traceback reporting later\n", |
| 199 | + "diejob1 = jobs.new(diefunc, 1)\n", |
| 200 | + "diejob2 = jobs.new(diefunc, 2)" |
| 201 | + ], |
| 202 | + "language": "python", |
| 203 | + "metadata": {}, |
| 204 | + "outputs": [ |
| 205 | + { |
| 206 | + "output_type": "stream", |
| 207 | + "stream": "stdout", |
| 208 | + "text": [ |
| 209 | + "Starting job # 4 in a separate thread.\n", |
| 210 | + "Starting job # 5 in a separate thread.\n" |
| 211 | + ] |
| 212 | + } |
| 213 | + ], |
164 | 214 | "prompt_number": 13
|
165 | 215 | },
|
166 | 216 | {
|
|
189 | 239 | "Status of diejob1: Dead (Exception), call jobs.traceback() for details\n",
|
190 | 240 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n",
|
191 | 241 | "\u001b[1;31mException\u001b[0m Traceback (most recent call last)\n",
|
192 |
| - "\u001b[1;32m/home/fperez/usr/lib/python2.7/site-packages/IPython/lib/backgroundjobs.pyc\u001b[0m in \u001b[0;36mcall\u001b[1;34m(self)\u001b[0m\n", |
| 242 | + "\u001b[1;32m/home/fperez/usr/opt/virtualenv/ipython-0.13.2/lib/python2.7/site-packages/IPython/lib/backgroundjobs.pyc\u001b[0m in \u001b[0;36mcall\u001b[1;34m(self)\u001b[0m\n", |
193 | 243 | "\u001b[0;32m 482\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
194 | 244 | "\u001b[0;32m 483\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mcall\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
195 | 245 | "\u001b[1;32m--> 484\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
205 | 255 | ]
|
206 | 256 | }
|
207 | 257 | ],
|
208 |
| - "prompt_number": 15 |
| 258 | + "prompt_number": 14 |
209 | 259 | },
|
210 | 260 | {
|
211 | 261 | "cell_type": "markdown",
|
|
227 | 277 | "output_type": "stream",
|
228 | 278 | "stream": "stdout",
|
229 | 279 | "text": [
|
230 |
| - "Traceback for: <BackgroundJob #4: <function diefunc at 0x2ef91b8>>\n", |
| 280 | + "Traceback for: <BackgroundJob #4: <function diefunc at 0x314f668>>\n", |
231 | 281 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n",
|
232 | 282 | "\u001b[1;31mException\u001b[0m Traceback (most recent call last)\n",
|
233 |
| - "\u001b[1;32m/home/fperez/usr/lib/python2.7/site-packages/IPython/lib/backgroundjobs.pyc\u001b[0m in \u001b[0;36mcall\u001b[1;34m(self)\u001b[0m\n", |
| 283 | + "\u001b[1;32m/home/fperez/usr/opt/virtualenv/ipython-0.13.2/lib/python2.7/site-packages/IPython/lib/backgroundjobs.pyc\u001b[0m in \u001b[0;36mcall\u001b[1;34m(self)\u001b[0m\n", |
234 | 284 | "\u001b[0;32m 482\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
235 | 285 | "\u001b[0;32m 483\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mcall\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
236 | 286 | "\u001b[1;32m--> 484\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
244 | 294 | "\n",
|
245 | 295 | "\u001b[1;31mException\u001b[0m: Dead job with interval 1\n",
|
246 | 296 | "\n",
|
247 |
| - "Traceback for: <BackgroundJob #5: <function diefunc at 0x2ef91b8>>\n", |
| 297 | + "Traceback for: <BackgroundJob #5: <function diefunc at 0x314f668>>\n", |
248 | 298 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n",
|
249 | 299 | "\u001b[1;31mException\u001b[0m Traceback (most recent call last)\n",
|
250 |
| - "\u001b[1;32m/home/fperez/usr/lib/python2.7/site-packages/IPython/lib/backgroundjobs.pyc\u001b[0m in \u001b[0;36mcall\u001b[1;34m(self)\u001b[0m\n", |
| 300 | + "\u001b[1;32m/home/fperez/usr/opt/virtualenv/ipython-0.13.2/lib/python2.7/site-packages/IPython/lib/backgroundjobs.pyc\u001b[0m in \u001b[0;36mcall\u001b[1;34m(self)\u001b[0m\n", |
251 | 301 | "\u001b[0;32m 482\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
252 | 302 | "\u001b[0;32m 483\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mcall\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
253 | 303 | "\u001b[1;32m--> 484\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
264 | 314 | ]
|
265 | 315 | }
|
266 | 316 | ],
|
267 |
| - "prompt_number": 16 |
| 317 | + "prompt_number": 15 |
268 | 318 | },
|
269 | 319 | {
|
270 | 320 | "cell_type": "markdown",
|
|
291 | 341 | ]
|
292 | 342 | }
|
293 | 343 | ],
|
294 |
| - "prompt_number": 17 |
| 344 | + "prompt_number": 16 |
295 | 345 | },
|
296 | 346 | {
|
297 | 347 | "cell_type": "markdown",
|
|
309 | 359 | "language": "python",
|
310 | 360 | "metadata": {},
|
311 | 361 | "outputs": [],
|
312 |
| - "prompt_number": 18 |
| 362 | + "prompt_number": 17 |
313 | 363 | },
|
314 | 364 | {
|
315 | 365 | "cell_type": "markdown",
|
|
336 | 386 | ]
|
337 | 387 | }
|
338 | 388 | ],
|
339 |
| - "prompt_number": 21 |
| 389 | + "prompt_number": 18 |
340 | 390 | },
|
341 | 391 | {
|
342 | 392 | "cell_type": "markdown",
|
|
0 commit comments