From ef8766d2f9466686b4fa1e930ad8d5c3ba71e40b 2014-07-31 06:42:41
From: Brian E. Granger <ellisonbg@gmail.com>
Date: 2014-07-31 06:42:41
Subject: [PATCH] Updating BG jobs nb from ipython-in-depth.

---

diff --git a/examples/IPython Kernel/Background Jobs.ipynb b/examples/IPython Kernel/Background Jobs.ipynb
index b0b561e..165f1cd 100644
--- a/examples/IPython Kernel/Background Jobs.ipynb
+++ b/examples/IPython Kernel/Background Jobs.ipynb
@@ -1,7 +1,6 @@
 {
  "metadata": {
-  "name": "",
-  "signature": "sha256:481e128e553ec13e039f3e3f5e567cc3caffe391b78b9821ee883fb8770ebc82"
+  "name": "BackgroundJobs"
  },
  "nbformat": 3,
  "nbformat_minor": 0,
@@ -9,17 +8,11 @@
   {
    "cells": [
     {
-     "cell_type": "heading",
-     "level": 1,
-     "metadata": {},
-     "source": [
-      "Background Jobs"
-     ]
-    },
-    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
+      "# Simple interactive bacgkround jobs with IPython\n",
+      "\n",
       "We start by loading the `backgroundjobs` library and defining a few trivial functions to illustrate things with."
      ]
     },
@@ -27,7 +20,6 @@
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "from __future__ import print_function\n",
       "from IPython.lib import backgroundjobs as bg\n",
       "\n",
       "import sys\n",
@@ -47,9 +39,9 @@
       "def printfunc(interval=1, reps=5):\n",
       "    for n in range(reps):\n",
       "        time.sleep(interval)\n",
-      "        print('In the background...', n)\n",
+      "        print 'In the background...', n\n",
       "        sys.stdout.flush()\n",
-      "    print('All done!')\n",
+      "    print 'All done!'\n",
       "    sys.stdout.flush()"
      ],
      "language": "python",
@@ -62,8 +54,8 @@
      "metadata": {},
      "source": [
       "Now, we can create a job manager (called simply `jobs`) and use it to submit new jobs.\n",
-      "<br>\n",
-      "Run the cell below and wait a few seconds for the whole thing to finish, until you see the \"All done!\" printout."
+      "\n",
+      "Run the cell below, it will show when the jobs start. Wait a few seconds until you see the 'all done' completion message:"
      ]
     },
     {
@@ -75,12 +67,7 @@
       "# Start a few jobs, the first one will have ID # 0\n",
       "jobs.new(sleepfunc, 4)\n",
       "jobs.new(sleepfunc, kw={'reps':2})\n",
-      "jobs.new('printfunc(1,3)')\n",
-      "\n",
-      "# This makes a couple of jobs which will die.  Let's keep a reference to\n",
-      "# them for easier traceback reporting later\n",
-      "diejob1 = jobs.new(diefunc, 1)\n",
-      "diejob2 = jobs.new(diefunc, 2)"
+      "jobs.new('printfunc(1,3)')"
      ],
      "language": "python",
      "metadata": {},
@@ -91,13 +78,46 @@
        "text": [
         "Starting job # 0 in a separate thread.\n",
         "Starting job # 2 in a separate thread.\n",
-        "Starting job # 3 in a separate thread.\n",
-        "Starting job # 4 in a separate thread.\n",
-        "Starting job # 5 in a separate thread.\n"
+        "Starting job # 3 in a separate thread.\n"
+       ]
+      },
+      {
+       "output_type": "pyout",
+       "prompt_number": 10,
+       "text": [
+        "<BackgroundJob #3: printfunc(1,3)>"
+       ]
+      },
+      {
+       "output_type": "stream",
+       "stream": "stdout",
+       "text": [
+        "In the background... 0\n"
+       ]
+      },
+      {
+       "output_type": "stream",
+       "stream": "stdout",
+       "text": [
+        "In the background... 1\n"
+       ]
+      },
+      {
+       "output_type": "stream",
+       "stream": "stdout",
+       "text": [
+        "In the background... 2\n"
+       ]
+      },
+      {
+       "output_type": "stream",
+       "stream": "stdout",
+       "text": [
+        "All done!\n"
        ]
       }
      ],
-     "prompt_number": 2
+     "prompt_number": 10
     },
     {
      "cell_type": "markdown",
@@ -119,27 +139,15 @@
        "output_type": "stream",
        "stream": "stdout",
        "text": [
-        "In the background... 0\n",
-        "Running jobs:"
-       ]
-      },
-      {
-       "output_type": "stream",
-       "stream": "stdout",
-       "text": [
-        "\n",
-        "0 : <function sleepfunc at 0x102cc6848>\n",
-        "2 : <function sleepfunc at 0x102cc6848>\n",
+        "Completed jobs:\n",
+        "0 : <function sleepfunc at 0x314f848>\n",
+        "2 : <function sleepfunc at 0x314f848>\n",
         "3 : printfunc(1,3)\n",
-        "5 : <function diefunc at 0x102cc68c0>\n",
-        "\n",
-        "Dead jobs:\n",
-        "4 : <function diefunc at 0x102cc68c0>\n",
         "\n"
        ]
       }
      ],
-     "prompt_number": 3
+     "prompt_number": 11
     },
     {
      "cell_type": "markdown",
@@ -152,14 +160,58 @@
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "jobs[0].result\n",
-      "j0 = jobs[0]\n",
-      "j0.join?"
+      "jobs[0].result"
      ],
      "language": "python",
      "metadata": {},
-     "outputs": [],
-     "prompt_number": 4
+     "outputs": [
+      {
+       "output_type": "pyout",
+       "prompt_number": 12,
+       "text": [
+        "{'args': (), 'interval': 4, 'kwargs': {}}"
+       ]
+      }
+     ],
+     "prompt_number": 12
+    },
+    {
+     "cell_type": "heading",
+     "level": 2,
+     "metadata": {},
+     "source": [
+      "Errors and tracebacks"
+     ]
+    },
+    {
+     "cell_type": "markdown",
+     "metadata": {},
+     "source": [
+      "The jobs manager tries to help you with debugging:"
+     ]
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "# This makes a couple of jobs which will die.  Let's keep a reference to\n",
+      "# them for easier traceback reporting later\n",
+      "diejob1 = jobs.new(diefunc, 1)\n",
+      "diejob2 = jobs.new(diefunc, 2)"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [
+      {
+       "output_type": "stream",
+       "stream": "stdout",
+       "text": [
+        "Starting job # 4 in a separate thread.\n",
+        "Starting job # 5 in a separate thread.\n"
+       ]
+      }
+     ],
+     "prompt_number": 13
     },
     {
      "cell_type": "markdown",
@@ -184,21 +236,26 @@
        "output_type": "stream",
        "stream": "stdout",
        "text": [
-        "In the background... 1\n",
-        "In the background... 2\n",
-        "All done!\n"
-       ]
-      },
-      {
-       "ename": "SyntaxError",
-       "evalue": "invalid syntax (<ipython-input-5-a90bd59af669>, line 1)",
-       "output_type": "pyerr",
-       "traceback": [
-        "\u001b[0;36m  File \u001b[0;32m\"<ipython-input-5-a90bd59af669>\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m    print \"Status of diejob1:\", diejob1.status\u001b[0m\n\u001b[0m                             ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
+        "Status of diejob1: Dead (Exception), call jobs.traceback() for details\n",
+        "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n",
+        "\u001b[1;31mException\u001b[0m                                 Traceback (most recent call last)\n",
+        "\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",
+        "\u001b[0;32m    482\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\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",
+        "\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",
+        "\u001b[0m\n",
+        "\u001b[1;32m<ipython-input-1-fbbbd0d2a1c3>\u001b[0m in \u001b[0;36mdiefunc\u001b[1;34m(interval, *a, **kw)\u001b[0m\n",
+        "\u001b[0;32m     13\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mdiefunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkw\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\u001b[0;32m     14\u001b[0m     \u001b[0mtime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\u001b[1;32m---> 15\u001b[1;33m     \u001b[1;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Dead job with interval %s\"\u001b[0m \u001b[1;33m%\u001b[0m \u001b[0minterval\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\u001b[0m\u001b[0;32m     16\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\u001b[0;32m     17\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mprintfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mreps\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\n",
+        "\u001b[1;31mException\u001b[0m: Dead job with interval 1\n"
        ]
       }
      ],
-     "prompt_number": 5
+     "prompt_number": 14
     },
     {
      "cell_type": "markdown",
@@ -220,44 +277,44 @@
        "output_type": "stream",
        "stream": "stdout",
        "text": [
-        "Traceback for: <BackgroundJob #4: <function diefunc at 0x102cc68c0>>\n",
-        "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n",
-        "\u001b[0;31mException\u001b[0m                                 Traceback (most recent call last)\n",
-        "\u001b[0;32m/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/lib/backgroundjobs.pyc\u001b[0m in \u001b[0;36mcall\u001b[0;34m(self)\u001b[0m\n",
-        "\u001b[1;32m    489\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
-        "\u001b[1;32m    490\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0mcall\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-        "\u001b[0;32m--> 491\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+        "Traceback for: <BackgroundJob #4: <function diefunc at 0x314f668>>\n",
+        "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n",
+        "\u001b[1;31mException\u001b[0m                                 Traceback (most recent call last)\n",
+        "\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",
+        "\u001b[0;32m    482\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\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",
+        "\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",
         "\u001b[0m\n",
-        "\u001b[0;32m<ipython-input-1-7391f8ae281b>\u001b[0m in \u001b[0;36mdiefunc\u001b[0;34m(interval, *a, **kw)\u001b[0m\n",
-        "\u001b[1;32m     14\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mdiefunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkw\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-        "\u001b[1;32m     15\u001b[0m     \u001b[0mtime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-        "\u001b[0;32m---> 16\u001b[0;31m     \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Dead job with interval %s\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0minterval\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-        "\u001b[0m\u001b[1;32m     17\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
-        "\u001b[1;32m     18\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mprintfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mreps\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+        "\u001b[1;32m<ipython-input-1-fbbbd0d2a1c3>\u001b[0m in \u001b[0;36mdiefunc\u001b[1;34m(interval, *a, **kw)\u001b[0m\n",
+        "\u001b[0;32m     13\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mdiefunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkw\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\u001b[0;32m     14\u001b[0m     \u001b[0mtime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\u001b[1;32m---> 15\u001b[1;33m     \u001b[1;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Dead job with interval %s\"\u001b[0m \u001b[1;33m%\u001b[0m \u001b[0minterval\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\u001b[0m\u001b[0;32m     16\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\u001b[0;32m     17\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mprintfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mreps\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
         "\n",
-        "\u001b[0;31mException\u001b[0m: Dead job with interval 1\n",
+        "\u001b[1;31mException\u001b[0m: Dead job with interval 1\n",
         "\n",
-        "Traceback for: <BackgroundJob #5: <function diefunc at 0x102cc68c0>>\n",
-        "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n",
-        "\u001b[0;31mException\u001b[0m                                 Traceback (most recent call last)\n",
-        "\u001b[0;32m/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/lib/backgroundjobs.pyc\u001b[0m in \u001b[0;36mcall\u001b[0;34m(self)\u001b[0m\n",
-        "\u001b[1;32m    489\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
-        "\u001b[1;32m    490\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0mcall\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-        "\u001b[0;32m--> 491\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+        "Traceback for: <BackgroundJob #5: <function diefunc at 0x314f668>>\n",
+        "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n",
+        "\u001b[1;31mException\u001b[0m                                 Traceback (most recent call last)\n",
+        "\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",
+        "\u001b[0;32m    482\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\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",
+        "\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",
         "\u001b[0m\n",
-        "\u001b[0;32m<ipython-input-1-7391f8ae281b>\u001b[0m in \u001b[0;36mdiefunc\u001b[0;34m(interval, *a, **kw)\u001b[0m\n",
-        "\u001b[1;32m     14\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mdiefunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkw\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-        "\u001b[1;32m     15\u001b[0m     \u001b[0mtime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-        "\u001b[0;32m---> 16\u001b[0;31m     \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Dead job with interval %s\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0minterval\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-        "\u001b[0m\u001b[1;32m     17\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
-        "\u001b[1;32m     18\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mprintfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mreps\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+        "\u001b[1;32m<ipython-input-1-fbbbd0d2a1c3>\u001b[0m in \u001b[0;36mdiefunc\u001b[1;34m(interval, *a, **kw)\u001b[0m\n",
+        "\u001b[0;32m     13\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mdiefunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkw\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\u001b[0;32m     14\u001b[0m     \u001b[0mtime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\u001b[1;32m---> 15\u001b[1;33m     \u001b[1;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Dead job with interval %s\"\u001b[0m \u001b[1;33m%\u001b[0m \u001b[0minterval\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\u001b[0m\u001b[0;32m     16\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
+        "\u001b[0;32m     17\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mprintfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mreps\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
         "\n",
-        "\u001b[0;31mException\u001b[0m: Dead job with interval 2\n",
+        "\u001b[1;31mException\u001b[0m: Dead job with interval 2\n",
         "\n"
        ]
       }
      ],
-     "prompt_number": 6
+     "prompt_number": 15
     },
     {
      "cell_type": "markdown",
@@ -284,7 +341,7 @@
        ]
       }
      ],
-     "prompt_number": 7
+     "prompt_number": 16
     },
     {
      "cell_type": "markdown",
@@ -302,13 +359,13 @@
      "language": "python",
      "metadata": {},
      "outputs": [],
-     "prompt_number": 8
+     "prompt_number": 17
     },
     {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
-      "It's easy to wait on a job:"
+      "Jobs have a `.join` method that lets you wait on their thread for completion:"
      ]
     },
     {
@@ -316,11 +373,7 @@
      "collapsed": false,
      "input": [
       "j = jobs.new(sleepfunc, 2)\n",
-      "print(\"Will wait for j now...\")\n",
-      "sys.stdout.flush()\n",
-      "j.join()\n",
-      "print(\"Result from j:\")\n",
-      "j.result"
+      "j.join?"
      ],
      "language": "python",
      "metadata": {},
@@ -329,27 +382,22 @@
        "output_type": "stream",
        "stream": "stdout",
        "text": [
-        "Starting job # 0 in a separate thread.\n",
-        "Will wait for j now...\n"
-       ]
-      },
-      {
-       "output_type": "stream",
-       "stream": "stdout",
-       "text": [
-        "Result from j:\n"
-       ]
-      },
-      {
-       "metadata": {},
-       "output_type": "pyout",
-       "prompt_number": 9,
-       "text": [
-        "{'args': (), 'interval': 2, 'kwargs': {}}"
+        "Starting job # 0 in a separate thread.\n"
        ]
       }
      ],
-     "prompt_number": 9
+     "prompt_number": 18
+    },
+    {
+     "cell_type": "markdown",
+     "metadata": {},
+     "source": [
+      "## Exercise\n",
+      "\n",
+      "1. Start a new job that calls `sleepfunc` with a 5-second wait\n",
+      "2. Print a short message that indicates you are waiting (note: you'll need to flush stdout to see that print output appear).\n",
+      "3. Wait on the job and then print its result."
+     ]
     }
    ],
    "metadata": {}