# Buggy code
def __new__(cls, *args, **kwargs):
    # Create a new instance
    instance = object.__new__(cls)
    # Add to the list of instances
    if "_instances" not in cls.__dict__:
        cls._instances = WeakSet()
    if "_lock" not in cls.__dict__:
        cls._lock = TqdmDefaultWriteLock()
    with cls._lock:
        cls._instances.add(instance)
    # Create the monitoring thread
    if cls.monitor_interval and (cls.monitor is None or not cls.monitor.report()):
        try:
            cls.monitor = TMonitor(cls, cls.monitor_interval)
        except Exception as e:  # pragma: nocover
            from warnings import warn

            warn(
                "tqdm:disabling monitor support"
                " (monitor_interval = 0) due to:\n" + str(e),
                RuntimeWarning,
            )
            cls.monitor_interval = 0
    # Return the instance
    return instance


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

## Package Plan ##

environment location: /exports/eddie/scratch/s1758208/minitest/envs/test


Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate test
#
# To deactivate an active environment, use
#
#     $ conda deactivate

[s1758208@login04(eddie) ~]$ conda activate test
(test) [s1758208@login04(eddie) ~]$ conda install python
Solving environment: done

## Package Plan ##

environment location: /exports/eddie/scratch/s1758208/minitest/envs/test

added / updated specs:
- python


The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
setuptools-38.5.1          |           py36_0         525 KB
libstdcxx-ng-7.2.0         |       hdf63c60_3         2.5 MB
libgcc-ng-7.2.0            |       hdf63c60_3         6.1 MB
pip-9.0.1                  |           py36_5         2.2 MB
python-3.6.4               |       hc3d631a_3        29.1 MB
------------------------------------------------------------
Total:        40.4 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
setuptools 38.5.1: ##################################################### | 100%
libstdcxx-ng 7.2.0: #################################################### | 100%

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

Traceback (most recent call last):
File "/exports/eddie/scratch/s1758208/minitest/lib/python3.6/site-packages/conda/exceptions.py", line 789, in __call__
return func(*args, **kwargs)
File "/exports/eddie/scratch/s1758208/minitest/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/exports/eddie/scratch/s1758208/minitest/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 77, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/exports/eddie/scratch/s1758208/minitest/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/exports/eddie/scratch/s1758208/minitest/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 "/exports/eddie/scratch/s1758208/minitest/lib/python3.6/site-packages/conda/cli/install.py", line 281, in handle_txn
progressive_fetch_extract.execute()
File "/exports/eddie/scratch/s1758208/minitest/lib/python3.6/site-packages/conda/core/package_cache.py", line 584, in execute
exc = self._execute_actions(prec_or_spec, prec_actions)
File "/exports/eddie/scratch/s1758208/minitest/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 "/exports/eddie/scratch/s1758208/minitest/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 "/exports/eddie/scratch/s1758208/minitest/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 388, in __new__
cls.monitor = TMonitor(cls, cls.monitor_interval)
File "/exports/eddie/scratch/s1758208/minitest/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 83, in __init__
self.start()
File "/exports/eddie/scratch/s1758208/minitest/lib/python3.6/threading.py", line 846, in start
_start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread

# Fixed code
def __new__(cls, *args, **kwargs):
    # Create a new instance
    instance = object.__new__(cls)
    # Add to the list of instances
    if "_instances" not in cls.__dict__:
        cls._instances = WeakSet()
    if "_lock" not in cls.__dict__:
        cls._lock = TqdmDefaultWriteLock()
    with cls._lock:
        cls._instances.add(instance)
    # Create the monitoring thread
    if cls.monitor_interval and (cls.monitor is None or not cls.monitor.report()):
        try:
            cls.monitor = TMonitor(cls, cls.monitor_interval)
        except Exception as e:  # pragma: nocover
            from warnings import warn

            warn(
                "tqdm:disabling monitor support"
                " (monitor_interval = 0) due to:\n" + str(e),
                TqdmMonitorWarning,
            )
            cls.monitor_interval = 0
    # Return the instance
    return instance