We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
psutil.NUM_CPUS deprecated and removed
``` python
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-5c5ee3cb747a> in <module>()
----> 1 import blaze

/home/skipper/.virtualenvs/py3/lib/python3.4/site-packages/blaze/__init__.py in <module>()
     16 
     17 from datashape import dshape, discover
---> 18 from .utils import ignoring
     19 from .expr import (Symbol, TableSymbol, symbol, ndim, shape)
     20 from .expr import (by, count, count_values, distinct, head, join, label, like,

/home/skipper/.virtualenvs/py3/lib/python3.4/site-packages/blaze/utils.py in <module>()
     25 from .dispatch import dispatch
     26 
---> 27 thread_pool = ThreadPool(psutil.NUM_CPUS)
     28 
     29 

AttributeError: 'module' object has no attribute 'NUM_CPUS'
```

```
Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
Type "copyright", "credits" or "license" for more information.

IPython 3.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
[TerminalIPythonApp] WARNING | File not found: '/home/skipper/.pystartup'
import pu
[~/]
[1]: import psutil

[~/]
[2]: psutil.__version__
[2]: '3.0.0'
```

https://github.com/giampaolo/psutil/issues/451


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `blaze/utils.py`
Content:
```
1 from __future__ import absolute_import, division, print_function
2 
3 import os
4 import datetime
5 from functools import wraps
6 
7 try:
8     from cytoolz import nth
9 except ImportError:
10     from toolz import nth
11 
12 from itertools import islice
13 from collections import Iterator
14 from multiprocessing.pool import ThreadPool
15 
16 # these are used throughout blaze, don't remove them
17 from odo.utils import tmpfile, filetext, filetexts, raises, keywords, ignoring
18 
19 import psutil
20 import numpy as np
21 
22 # Imports that replace older utils.
23 from .compatibility import map, zip
24 
25 from .dispatch import dispatch
26 
27 thread_pool = ThreadPool(psutil.NUM_CPUS)
28 
29 
30 def nth_list(n, seq):
31     """
32 
33     >>> tuple(nth_list([0, 1, 4], 'Hello'))
34     ('H', 'e', 'o')
35     >>> tuple(nth_list([4, 1, 0], 'Hello'))
36     ('o', 'e', 'H')
37     >>> tuple(nth_list([0, 0, 0], 'Hello'))
38     ('H', 'H', 'H')
39     """
40     seq = iter(seq)
41 
42     result = []
43     old = 0
44     item = next(seq)
45     for index in sorted(n):
46         for i in range(index - old):
47             item = next(seq)
48         result.append(item)
49         old = index
50 
51     order = [x[1] for x in sorted(zip(n, range(len(n))))]
52     return (result[i] for i in order)
53 
54 
55 def get(ind, coll, lazy=False):
56     """
57 
58     >>> get(0, 'Hello')
59     'H'
60 
61     >>> get([1, 0], 'Hello')
62     ('e', 'H')
63 
64     >>> get(slice(1, 4), 'Hello')
65     ('e', 'l', 'l')
66 
67     >>> get(slice(1, 4), 'Hello', lazy=True)
68     <itertools.islice object at ...>
69     """
70     if isinstance(ind, list):
71         result = nth_list(ind, coll)
72     elif isinstance(ind, slice):
73         result = islice(coll, ind.start, ind.stop, ind.step)
74     else:
75         if isinstance(coll, Iterator):
76             result = nth(ind, coll)
77         else:
78             result = coll[ind]
79     if not lazy and isinstance(result, Iterator):
80         result = tuple(result)
81     return result
82 
83 
84 def ndget(ind, data):
85     """
86     Get from N-Dimensional getable
87 
88     Can index with elements, lists, or slices.  Mimic's numpy fancy indexing on
89     generic indexibles.
90 
91     >>> data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
92     >>> ndget(0, data)
93     [[1, 2], [3, 4]]
94     >>> ndget((0, 1), data)
95     [3, 4]
96     >>> ndget((0, 0, 0), data)
97     1
98     >>> ndget((slice(0, 2), [0, 1], 0), data)
99     ((1, 3), (5, 7))
100     """
101     if isinstance(ind, tuple) and len(ind) == 1:
102         ind = ind[0]
103     if not isinstance(ind, tuple):
104         return get(ind, data)
105     result = get(ind[0], data)
106     if isinstance(ind[0], (list, slice)):
107         return type(result)(ndget(ind[1:], row) for row in result)
108     else:
109         return ndget(ind[1:], result)
110 
111 
112 def normalize_to_date(dt):
113     if isinstance(dt, datetime.datetime) and not dt.time():
114         return dt.date()
115     else:
116         return dt
117 
118 
119 def assert_allclose(lhs, rhs):
120     for tb in map(zip, lhs, rhs):
121         for left, right in tb:
122             if isinstance(left, (np.floating, float)):
123                 # account for nans
124                 assert np.all(np.isclose(left, right, equal_nan=True))
125                 continue
126             if isinstance(left, datetime.datetime):
127                 left = normalize_to_date(left)
128             if isinstance(right, datetime.datetime):
129                 right = normalize_to_date(right)
130             assert left == right
131 
132 
133 def example(filename, datapath=os.path.join('examples', 'data')):
134     import blaze
135     return os.path.join(os.path.dirname(blaze.__file__), datapath, filename)
136 
137 
138 def available_memory():
139     return psutil.virtual_memory().available
140 
141 
142 def listpack(x):
143     """
144     >>> listpack(1)
145     [1]
146     >>> listpack((1, 2))
147     [1, 2]
148     >>> listpack([1, 2])
149     [1, 2]
150     """
151     if isinstance(x, tuple):
152         return list(x)
153     elif isinstance(x, list):
154         return x
155     else:
156         return [x]
157 
158 
159 @dispatch(datetime.datetime)
160 def json_dumps(dt):
161     s = dt.isoformat()
162     if not dt.tzname():
163         s += 'Z'
164     return s
165
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/blaze/utils.py b/blaze/utils.py
--- a/blaze/utils.py
+++ b/blaze/utils.py
@@ -24,7 +24,7 @@
 
 from .dispatch import dispatch
 
-thread_pool = ThreadPool(psutil.NUM_CPUS)
+thread_pool = ThreadPool(psutil.cpu_count())
 
 
 def nth_list(n, seq):

{"golden_diff": "diff --git a/blaze/utils.py b/blaze/utils.py\n--- a/blaze/utils.py\n+++ b/blaze/utils.py\n@@ -24,7 +24,7 @@\n \n from .dispatch import dispatch\n \n-thread_pool = ThreadPool(psutil.NUM_CPUS)\n+thread_pool = ThreadPool(psutil.cpu_count())\n \n \n def nth_list(n, seq):\n", "issue": "psutil.NUM_CPUS deprecated and removed\n``` python\n---------------------------------------------------------------------------\nAttributeError                            Traceback (most recent call last)\n<ipython-input-11-5c5ee3cb747a> in <module>()\n----> 1 import blaze\n\n/home/skipper/.virtualenvs/py3/lib/python3.4/site-packages/blaze/__init__.py in <module>()\n     16 \n     17 from datashape import dshape, discover\n---> 18 from .utils import ignoring\n     19 from .expr import (Symbol, TableSymbol, symbol, ndim, shape)\n     20 from .expr import (by, count, count_values, distinct, head, join, label, like,\n\n/home/skipper/.virtualenvs/py3/lib/python3.4/site-packages/blaze/utils.py in <module>()\n     25 from .dispatch import dispatch\n     26 \n---> 27 thread_pool = ThreadPool(psutil.NUM_CPUS)\n     28 \n     29 \n\nAttributeError: 'module' object has no attribute 'NUM_CPUS'\n```\n\n```\nPython 3.4.0 (default, Apr 11 2014, 13:05:11) \nType \"copyright\", \"credits\" or \"license\" for more information.\n\nIPython 3.1.0 -- An enhanced Interactive Python.\n?         -> Introduction and overview of IPython's features.\n%quickref -> Quick reference.\nhelp      -> Python's own help system.\nobject?   -> Details about 'object', use 'object??' for extra details.\n[TerminalIPythonApp] WARNING | File not found: '/home/skipper/.pystartup'\nimport pu\n[~/]\n[1]: import psutil\n\n[~/]\n[2]: psutil.__version__\n[2]: '3.0.0'\n```\n\nhttps://github.com/giampaolo/psutil/issues/451\n\n", "before_files": [{"content": "from __future__ import absolute_import, division, print_function\n\nimport os\nimport datetime\nfrom functools import wraps\n\ntry:\n    from cytoolz import nth\nexcept ImportError:\n    from toolz import nth\n\nfrom itertools import islice\nfrom collections import Iterator\nfrom multiprocessing.pool import ThreadPool\n\n# these are used throughout blaze, don't remove them\nfrom odo.utils import tmpfile, filetext, filetexts, raises, keywords, ignoring\n\nimport psutil\nimport numpy as np\n\n# Imports that replace older utils.\nfrom .compatibility import map, zip\n\nfrom .dispatch import dispatch\n\nthread_pool = ThreadPool(psutil.NUM_CPUS)\n\n\ndef nth_list(n, seq):\n    \"\"\"\n\n    >>> tuple(nth_list([0, 1, 4], 'Hello'))\n    ('H', 'e', 'o')\n    >>> tuple(nth_list([4, 1, 0], 'Hello'))\n    ('o', 'e', 'H')\n    >>> tuple(nth_list([0, 0, 0], 'Hello'))\n    ('H', 'H', 'H')\n    \"\"\"\n    seq = iter(seq)\n\n    result = []\n    old = 0\n    item = next(seq)\n    for index in sorted(n):\n        for i in range(index - old):\n            item = next(seq)\n        result.append(item)\n        old = index\n\n    order = [x[1] for x in sorted(zip(n, range(len(n))))]\n    return (result[i] for i in order)\n\n\ndef get(ind, coll, lazy=False):\n    \"\"\"\n\n    >>> get(0, 'Hello')\n    'H'\n\n    >>> get([1, 0], 'Hello')\n    ('e', 'H')\n\n    >>> get(slice(1, 4), 'Hello')\n    ('e', 'l', 'l')\n\n    >>> get(slice(1, 4), 'Hello', lazy=True)\n    <itertools.islice object at ...>\n    \"\"\"\n    if isinstance(ind, list):\n        result = nth_list(ind, coll)\n    elif isinstance(ind, slice):\n        result = islice(coll, ind.start, ind.stop, ind.step)\n    else:\n        if isinstance(coll, Iterator):\n            result = nth(ind, coll)\n        else:\n            result = coll[ind]\n    if not lazy and isinstance(result, Iterator):\n        result = tuple(result)\n    return result\n\n\ndef ndget(ind, data):\n    \"\"\"\n    Get from N-Dimensional getable\n\n    Can index with elements, lists, or slices.  Mimic's numpy fancy indexing on\n    generic indexibles.\n\n    >>> data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]\n    >>> ndget(0, data)\n    [[1, 2], [3, 4]]\n    >>> ndget((0, 1), data)\n    [3, 4]\n    >>> ndget((0, 0, 0), data)\n    1\n    >>> ndget((slice(0, 2), [0, 1], 0), data)\n    ((1, 3), (5, 7))\n    \"\"\"\n    if isinstance(ind, tuple) and len(ind) == 1:\n        ind = ind[0]\n    if not isinstance(ind, tuple):\n        return get(ind, data)\n    result = get(ind[0], data)\n    if isinstance(ind[0], (list, slice)):\n        return type(result)(ndget(ind[1:], row) for row in result)\n    else:\n        return ndget(ind[1:], result)\n\n\ndef normalize_to_date(dt):\n    if isinstance(dt, datetime.datetime) and not dt.time():\n        return dt.date()\n    else:\n        return dt\n\n\ndef assert_allclose(lhs, rhs):\n    for tb in map(zip, lhs, rhs):\n        for left, right in tb:\n            if isinstance(left, (np.floating, float)):\n                # account for nans\n                assert np.all(np.isclose(left, right, equal_nan=True))\n                continue\n            if isinstance(left, datetime.datetime):\n                left = normalize_to_date(left)\n            if isinstance(right, datetime.datetime):\n                right = normalize_to_date(right)\n            assert left == right\n\n\ndef example(filename, datapath=os.path.join('examples', 'data')):\n    import blaze\n    return os.path.join(os.path.dirname(blaze.__file__), datapath, filename)\n\n\ndef available_memory():\n    return psutil.virtual_memory().available\n\n\ndef listpack(x):\n    \"\"\"\n    >>> listpack(1)\n    [1]\n    >>> listpack((1, 2))\n    [1, 2]\n    >>> listpack([1, 2])\n    [1, 2]\n    \"\"\"\n    if isinstance(x, tuple):\n        return list(x)\n    elif isinstance(x, list):\n        return x\n    else:\n        return [x]\n\n\n@dispatch(datetime.datetime)\ndef json_dumps(dt):\n    s = dt.isoformat()\n    if not dt.tzname():\n        s += 'Z'\n    return s\n", "path": "blaze/utils.py"}], "after_files": [{"content": "from __future__ import absolute_import, division, print_function\n\nimport os\nimport datetime\nfrom functools import wraps\n\ntry:\n    from cytoolz import nth\nexcept ImportError:\n    from toolz import nth\n\nfrom itertools import islice\nfrom collections import Iterator\nfrom multiprocessing.pool import ThreadPool\n\n# these are used throughout blaze, don't remove them\nfrom odo.utils import tmpfile, filetext, filetexts, raises, keywords, ignoring\n\nimport psutil\nimport numpy as np\n\n# Imports that replace older utils.\nfrom .compatibility import map, zip\n\nfrom .dispatch import dispatch\n\nthread_pool = ThreadPool(psutil.cpu_count())\n\n\ndef nth_list(n, seq):\n    \"\"\"\n\n    >>> tuple(nth_list([0, 1, 4], 'Hello'))\n    ('H', 'e', 'o')\n    >>> tuple(nth_list([4, 1, 0], 'Hello'))\n    ('o', 'e', 'H')\n    >>> tuple(nth_list([0, 0, 0], 'Hello'))\n    ('H', 'H', 'H')\n    \"\"\"\n    seq = iter(seq)\n\n    result = []\n    old = 0\n    item = next(seq)\n    for index in sorted(n):\n        for i in range(index - old):\n            item = next(seq)\n        result.append(item)\n        old = index\n\n    order = [x[1] for x in sorted(zip(n, range(len(n))))]\n    return (result[i] for i in order)\n\n\ndef get(ind, coll, lazy=False):\n    \"\"\"\n\n    >>> get(0, 'Hello')\n    'H'\n\n    >>> get([1, 0], 'Hello')\n    ('e', 'H')\n\n    >>> get(slice(1, 4), 'Hello')\n    ('e', 'l', 'l')\n\n    >>> get(slice(1, 4), 'Hello', lazy=True)\n    <itertools.islice object at ...>\n    \"\"\"\n    if isinstance(ind, list):\n        result = nth_list(ind, coll)\n    elif isinstance(ind, slice):\n        result = islice(coll, ind.start, ind.stop, ind.step)\n    else:\n        if isinstance(coll, Iterator):\n            result = nth(ind, coll)\n        else:\n            result = coll[ind]\n    if not lazy and isinstance(result, Iterator):\n        result = tuple(result)\n    return result\n\n\ndef ndget(ind, data):\n    \"\"\"\n    Get from N-Dimensional getable\n\n    Can index with elements, lists, or slices.  Mimic's numpy fancy indexing on\n    generic indexibles.\n\n    >>> data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]\n    >>> ndget(0, data)\n    [[1, 2], [3, 4]]\n    >>> ndget((0, 1), data)\n    [3, 4]\n    >>> ndget((0, 0, 0), data)\n    1\n    >>> ndget((slice(0, 2), [0, 1], 0), data)\n    ((1, 3), (5, 7))\n    \"\"\"\n    if isinstance(ind, tuple) and len(ind) == 1:\n        ind = ind[0]\n    if not isinstance(ind, tuple):\n        return get(ind, data)\n    result = get(ind[0], data)\n    if isinstance(ind[0], (list, slice)):\n        return type(result)(ndget(ind[1:], row) for row in result)\n    else:\n        return ndget(ind[1:], result)\n\n\ndef normalize_to_date(dt):\n    if isinstance(dt, datetime.datetime) and not dt.time():\n        return dt.date()\n    else:\n        return dt\n\n\ndef assert_allclose(lhs, rhs):\n    for tb in map(zip, lhs, rhs):\n        for left, right in tb:\n            if isinstance(left, (np.floating, float)):\n                # account for nans\n                assert np.all(np.isclose(left, right, equal_nan=True))\n                continue\n            if isinstance(left, datetime.datetime):\n                left = normalize_to_date(left)\n            if isinstance(right, datetime.datetime):\n                right = normalize_to_date(right)\n            assert left == right\n\n\ndef example(filename, datapath=os.path.join('examples', 'data')):\n    import blaze\n    return os.path.join(os.path.dirname(blaze.__file__), datapath, filename)\n\n\ndef available_memory():\n    return psutil.virtual_memory().available\n\n\ndef listpack(x):\n    \"\"\"\n    >>> listpack(1)\n    [1]\n    >>> listpack((1, 2))\n    [1, 2]\n    >>> listpack([1, 2])\n    [1, 2]\n    \"\"\"\n    if isinstance(x, tuple):\n        return list(x)\n    elif isinstance(x, list):\n        return x\n    else:\n        return [x]\n\n\n@dispatch(datetime.datetime)\ndef json_dumps(dt):\n    s = dt.isoformat()\n    if not dt.tzname():\n        s += 'Z'\n    return s\n", "path": "blaze/utils.py"}]}