# Buggy code
def status_printer(_, total=None, desc=None):
    """
    Manage the printing of an IPython/Jupyter Notebook progress bar widget.
    """
    # Fallback to text bar if there's no total
    # DEPRECATED: replaced with an 'info' style bar
    # if not total:
    #    return super(tqdm_notebook, tqdm_notebook).status_printer(file)

    # fp = file

    # Prepare IPython progress bar
    if total:
        pbar = IntProgress(min=0, max=total)
    else:  # No total? Show info style bar with no progress tqdm status
        pbar = IntProgress(min=0, max=1)
        pbar.value = 1
        pbar.bar_style = "info"
    if desc:
        pbar.description = desc
    # Prepare status text
    ptext = HTML()
    # Only way to place text to the right of the bar is to use a container
    container = HBox(children=[pbar, ptext])
    display(container)

    def print_status(s="", close=False, bar_style=None):
        # Note: contrary to native tqdm, s='' does NOT clear bar
        # goal is to keep all infos if error happens so user knows
        # at which iteration the loop failed.

        # Clear previous output (really necessary?)
        # clear_output(wait=1)

        # Get current iteration value from format_meter string
        if total:
            n = None
            if s:
                npos = s.find(r"/|/")  # cause we use bar_format=r'{n}|...'
                # Check that n can be found in s (else n > total)
                if npos >= 0:
                    n = int(s[:npos])  # get n from string
                    s = s[npos + 3 :]  # remove from string

                    # Update bar with current n value
                    if n is not None:
                        pbar.value = n

        # Print stats
        if s:  # never clear the bar (signal: s='')
            s = s.replace("||", "")  # remove inesthetical pipes
            s = escape(s)  # html escape special characters (like '?')
            ptext.value = s

        # Change bar style
        if bar_style:
            # Hack-ish way to avoid the danger bar_style being overriden by
            # success because the bar gets closed after the error...
            if not (pbar.bar_style == "danger" and bar_style == "success"):
                pbar.bar_style = bar_style

        # Special signal to close the bar
        if close and pbar.bar_style != "danger":  # hide only if no error
            container.visible = False

    return print_status


# Traceback (RuntimeError)
[s1758208@login04(eddie) ~]$ conda create -n test
[s1758208@login04(eddie) ~]$ conda activate test
(test) [s1758208@login04(eddie) ~]$ conda install python
Solving environment: done

## Package Plan ##

environment location: /exports/csce/eddie/ph/groups/rbm_ml/michael/myconda/envs/test

added / updated specs:
- python


The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
python-3.6.4               |       hc3d631a_3        29.1 MB
libstdcxx-ng-7.2.0         |       hdf63c60_3         2.5 MB
certifi-2018.1.18          |           py36_0         144 KB
zlib-1.2.11                |       ha838bed_2         101 KB
sqlite-3.22.0              |       h1bed415_0         1.5 MB
wheel-0.30.0               |   py36hfd4bba0_1          67 KB
openssl-1.0.2n             |       hb7f436b_0         3.4 MB
libffi-3.2.1               |       hd88cf55_4          43 KB
libgcc-ng-7.2.0            |       hdf63c60_3         6.1 MB
ncurses-6.0                |       h9df7e31_2         920 KB
tk-8.6.7                   |       hc745277_3         3.2 MB
setuptools-38.5.1          |           py36_0         525 KB
pip-9.0.1                  |           py36_5         2.2 MB
libedit-3.1                |       heed3624_0         171 KB
ca-certificates-2017.08.26 |       h1d4fec5_0         263 KB
------------------------------------------------------------
Total:        50.2 MB

The following NEW packages will be INSTALLED:

ca-certificates: 2017.08.26-h1d4fec5_0
certifi:         2018.1.18-py36_0
libedit:         3.1-heed3624_0
libffi:          3.2.1-hd88cf55_4
libgcc-ng:       7.2.0-hdf63c60_3
libstdcxx-ng:    7.2.0-hdf63c60_3
ncurses:         6.0-h9df7e31_2
openssl:         1.0.2n-hb7f436b_0
pip:             9.0.1-py36_5
python:          3.6.4-hc3d631a_3
readline:        7.0-ha6073c6_4
setuptools:      38.5.1-py36_0
sqlite:          3.22.0-h1bed415_0
tk:              8.6.7-hc745277_3
wheel:           0.30.0-py36hfd4bba0_1
xz:              5.2.3-h55aa19d_2
zlib:            1.2.11-ha838bed_2

Proceed ([y]/n)? y


Downloading and Extracting Packages
python 3.6.4: ########################################################## | 100%
libstdcxx-ng 7.2.0: #################################################### | 100%
certifi 2018.1.18: ##################################################### | 100%

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

Traceback (most recent call last):
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/exceptions.py", line 789, in __call__
return func(*args, **kwargs)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 77, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/cli/install.py", line 255, in install
handle_txn(progressive_fetch_extract, unlink_link_transaction, prefix, args, newenv)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/cli/install.py", line 281, in handle_txn
progressive_fetch_extract.execute()
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 584, in execute
exc = self._execute_actions(prec_or_spec, prec_actions)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 599, in _execute_actions
progress_bar = ProgressBar(desc, not context.verbosity and not context.quiet, context.json)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/common/io.py", line 390, in __init__
self.pbar = tqdm(desc=description, bar_format=bar_format, ascii=True, total=1)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 388, in __new__
cls.monitor = TMonitor(cls, cls.monitor_interval)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 83, in __init__
self.start()
File "/home/s1758208/miniconda3/lib/python3.6/threading.py", line 846, in start
_start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread

# Fixed code
def status_printer(_, total=None, desc=None):
    """
    Manage the printing of an IPython/Jupyter Notebook progress bar widget.
    """
    # Fallback to text bar if there's no total
    # DEPRECATED: replaced with an 'info' style bar
    # if not total:
    #    return super(tqdm_notebook, tqdm_notebook).status_printer(file)

    # fp = file

    # Prepare IPython progress bar
    if total:
        pbar = IntProgress(min=0, max=total)
    else:  # No total? Show info style bar with no progress tqdm status
        pbar = IntProgress(min=0, max=1)
        pbar.value = 1
        pbar.bar_style = "info"
    if desc:
        pbar.description = desc
    # Prepare status text
    ptext = HTML()
    # Only way to place text to the right of the bar is to use a container
    container = HBox(children=[pbar, ptext])
    display(container)

    def print_status(s="", close=False, bar_style=None, desc=None):
        # Note: contrary to native tqdm, s='' does NOT clear bar
        # goal is to keep all infos if error happens so user knows
        # at which iteration the loop failed.

        # Clear previous output (really necessary?)
        # clear_output(wait=1)

        # Get current iteration value from format_meter string
        if total:
            # n = None
            if s:
                npos = s.find(r"/|/")  # cause we use bar_format=r'{n}|...'
                # Check that n can be found in s (else n > total)
                if npos >= 0:
                    n = int(s[:npos])  # get n from string
                    s = s[npos + 3 :]  # remove from string

                    # Update bar with current n value
                    if n is not None:
                        pbar.value = n

        # Print stats
        if s:  # never clear the bar (signal: s='')
            s = s.replace("||", "")  # remove inesthetical pipes
            s = escape(s)  # html escape special characters (like '?')
            ptext.value = s

        # Change bar style
        if bar_style:
            # Hack-ish way to avoid the danger bar_style being overriden by
            # success because the bar gets closed after the error...
            if not (pbar.bar_style == "danger" and bar_style == "success"):
                pbar.bar_style = bar_style

        # Special signal to close the bar
        if close and pbar.bar_style != "danger":  # hide only if no error
            try:
                container.close()
            except AttributeError:
                container.visible = False

        # Update description
        if desc:
            pbar.description = desc

    return print_status