We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Compile and execute use a progress bar even if a single circuit is passed.
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Informations

- **Qiskit Terra version**: master
- **Python version**: 3.7
- **Operating system**: OSX

### What is the current behavior?
The `compile` and `execute` functions make use of a progress bar for a single circuit.

### Steps to reproduce the problem
```
from qiskit import *
from qiskit.tools.jupyter import TextProgressBar

q = QuantumRegister(2)
c = ClassicalRegister(2)
qc = QuantumCircuit(q, c)

qc.h(q[0])
qc.cx(q[0], q[1])
qc.measure(q, c)

backend = Aer.get_backend('qasm_simulator')
TextProgressBar()
qobj = compile([qc], backend)
```


### What is the expected behavior?
A progress bar should not be used for a single circuit.

### Suggested solutions




--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `qiskit/transpiler/_parallel.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 # Copyright 2018, IBM.
4 #
5 # This source code is licensed under the Apache License, Version 2.0 found in
6 # the LICENSE.txt file in the root directory of this source tree.
7 
8 # This file is part of QuTiP: Quantum Toolbox in Python.
9 #
10 #    Copyright (c) 2011 and later, Paul D. Nation and Robert J. Johansson.
11 #    All rights reserved.
12 #
13 #    Redistribution and use in source and binary forms, with or without
14 #    modification, are permitted provided that the following conditions are
15 #    met:
16 #
17 #    1. Redistributions of source code must retain the above copyright notice,
18 #       this list of conditions and the following disclaimer.
19 #
20 #    2. Redistributions in binary form must reproduce the above copyright
21 #       notice, this list of conditions and the following disclaimer in the
22 #       documentation and/or other materials provided with the distribution.
23 #
24 #    3. Neither the name of the QuTiP: Quantum Toolbox in Python nor the names
25 #       of its contributors may be used to endorse or promote products derived
26 #       from this software without specific prior written permission.
27 #
28 #    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 #    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 #    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
31 #    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 #    HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 #    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 #    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 #    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 #    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 #    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 #    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ###############################################################################
40 
41 """
42 Routines for running Python functions in parallel using process pools
43 from the multiprocessing library.
44 """
45 
46 import os
47 import platform
48 from multiprocessing import Pool
49 from qiskit._qiskiterror import QISKitError
50 from qiskit._util import local_hardware_info
51 from qiskit._pubsub import Publisher
52 
53 # Number of local physical cpus
54 CPU_COUNT = local_hardware_info()['cpus']
55 
56 
57 def parallel_map(task, values, task_args=tuple(), task_kwargs={},  # pylint: disable=W0102
58                  num_processes=CPU_COUNT):
59     """
60     Parallel execution of a mapping of `values` to the function `task`. This
61     is functionally equivalent to::
62 
63         result = [task(value, *task_args, **task_kwargs) for value in values]
64 
65     On Windows this function defaults to a serial implementation to avoid the
66     overhead from spawning processes in Windows.
67 
68     Args:
69         task (func): Function that is to be called for each value in ``task_vec``.
70         values (array_like): List or array of values for which the ``task``
71                             function is to be evaluated.
72         task_args (list): Optional additional arguments to the ``task`` function.
73         task_kwargs (dict): Optional additional keyword argument to the ``task`` function.
74         num_processes (int): Number of processes to spawn.
75 
76     Returns:
77         result: The result list contains the value of
78                 ``task(value, *task_args, **task_kwargs)`` for
79                     each value in ``values``.
80 
81     Raises:
82         QISKitError: If user interrupts via keyboard.
83 
84     Events:
85         terra.transpiler.parallel.start: The collection of parallel tasks are about to start.
86         terra.transpiler.parallel.update: One of the parallel task has finished.
87         terra.transpiler.parallel.finish: All the parallel tasks have finished.
88     """
89     Publisher().publish("terra.transpiler.parallel.start", len(values))
90     if len(values) == 1:
91         Publisher().publish("terra.transpiler.parallel.finish")
92         return [task(values[0], *task_args, **task_kwargs)]
93 
94     nfinished = [0]
95 
96     def _callback(_):
97         nfinished[0] += 1
98         Publisher().publish("terra.transpiler.parallel.done", nfinished[0])
99 
100     # Run in parallel if not Win and not in parallel already
101     if platform.system() != 'Windows' and num_processes > 1 \
102        and os.getenv('QISKIT_IN_PARALLEL') == 'FALSE':
103         os.environ['QISKIT_IN_PARALLEL'] = 'TRUE'
104         try:
105             pool = Pool(processes=num_processes)
106 
107             async_res = [pool.apply_async(task, (value,) + task_args, task_kwargs,
108                                           _callback) for value in values]
109 
110             while not all([item.ready() for item in async_res]):
111                 for item in async_res:
112                     item.wait(timeout=0.1)
113 
114             pool.terminate()
115             pool.join()
116 
117         except KeyboardInterrupt:
118             pool.terminate()
119             pool.join()
120             Publisher().publish("terra.parallel.parallel.finish")
121             raise QISKitError('Keyboard interrupt in parallel_map.')
122 
123         Publisher().publish("terra.transpiler.parallel.finish")
124         os.environ['QISKIT_IN_PARALLEL'] = 'FALSE'
125         return [ar.get() for ar in async_res]
126 
127     # Cannot do parallel on Windows , if another parallel_map is running in parallel,
128     # or len(values) == 1.
129     results = []
130     for _, value in enumerate(values):
131         result = task(value, *task_args, **task_kwargs)
132         results.append(result)
133         _callback(0)
134     Publisher().publish("terra.transpiler.parallel.finish")
135     return results
136
```
--- 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/qiskit/transpiler/_parallel.py b/qiskit/transpiler/_parallel.py
--- a/qiskit/transpiler/_parallel.py
+++ b/qiskit/transpiler/_parallel.py
@@ -86,11 +86,10 @@
         terra.transpiler.parallel.update: One of the parallel task has finished.
         terra.transpiler.parallel.finish: All the parallel tasks have finished.
     """
-    Publisher().publish("terra.transpiler.parallel.start", len(values))
     if len(values) == 1:
-        Publisher().publish("terra.transpiler.parallel.finish")
         return [task(values[0], *task_args, **task_kwargs)]
 
+    Publisher().publish("terra.transpiler.parallel.start", len(values))
     nfinished = [0]
 
     def _callback(_):

{"golden_diff": "diff --git a/qiskit/transpiler/_parallel.py b/qiskit/transpiler/_parallel.py\n--- a/qiskit/transpiler/_parallel.py\n+++ b/qiskit/transpiler/_parallel.py\n@@ -86,11 +86,10 @@\n         terra.transpiler.parallel.update: One of the parallel task has finished.\n         terra.transpiler.parallel.finish: All the parallel tasks have finished.\n     \"\"\"\n-    Publisher().publish(\"terra.transpiler.parallel.start\", len(values))\n     if len(values) == 1:\n-        Publisher().publish(\"terra.transpiler.parallel.finish\")\n         return [task(values[0], *task_args, **task_kwargs)]\n \n+    Publisher().publish(\"terra.transpiler.parallel.start\", len(values))\n     nfinished = [0]\n \n     def _callback(_):\n", "issue": "Compile and execute use a progress bar even if a single circuit is passed.\n<!-- \u26a0\ufe0f If you do not respect this template, your issue will be closed -->\r\n<!-- \u26a0\ufe0f Make sure to browse the opened and closed issues -->\r\n\r\n### Informations\r\n\r\n- **Qiskit Terra version**: master\r\n- **Python version**: 3.7\r\n- **Operating system**: OSX\r\n\r\n### What is the current behavior?\r\nThe `compile` and `execute` functions make use of a progress bar for a single circuit.\r\n\r\n### Steps to reproduce the problem\r\n```\r\nfrom qiskit import *\r\nfrom qiskit.tools.jupyter import TextProgressBar\r\n\r\nq = QuantumRegister(2)\r\nc = ClassicalRegister(2)\r\nqc = QuantumCircuit(q, c)\r\n\r\nqc.h(q[0])\r\nqc.cx(q[0], q[1])\r\nqc.measure(q, c)\r\n\r\nbackend = Aer.get_backend('qasm_simulator')\r\nTextProgressBar()\r\nqobj = compile([qc], backend)\r\n```\r\n\r\n\r\n### What is the expected behavior?\r\nA progress bar should not be used for a single circuit.\r\n\r\n### Suggested solutions\r\n\r\n\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright 2018, IBM.\n#\n# This source code is licensed under the Apache License, Version 2.0 found in\n# the LICENSE.txt file in the root directory of this source tree.\n\n# This file is part of QuTiP: Quantum Toolbox in Python.\n#\n#    Copyright (c) 2011 and later, Paul D. Nation and Robert J. Johansson.\n#    All rights reserved.\n#\n#    Redistribution and use in source and binary forms, with or without\n#    modification, are permitted provided that the following conditions are\n#    met:\n#\n#    1. Redistributions of source code must retain the above copyright notice,\n#       this list of conditions and the following disclaimer.\n#\n#    2. Redistributions in binary form must reproduce the above copyright\n#       notice, this list of conditions and the following disclaimer in the\n#       documentation and/or other materials provided with the distribution.\n#\n#    3. Neither the name of the QuTiP: Quantum Toolbox in Python nor the names\n#       of its contributors may be used to endorse or promote products derived\n#       from this software without specific prior written permission.\n#\n#    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n#    \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n#    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n#    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n#    HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n#    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n#    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n#    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n#    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n#    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n#    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n###############################################################################\n\n\"\"\"\nRoutines for running Python functions in parallel using process pools\nfrom the multiprocessing library.\n\"\"\"\n\nimport os\nimport platform\nfrom multiprocessing import Pool\nfrom qiskit._qiskiterror import QISKitError\nfrom qiskit._util import local_hardware_info\nfrom qiskit._pubsub import Publisher\n\n# Number of local physical cpus\nCPU_COUNT = local_hardware_info()['cpus']\n\n\ndef parallel_map(task, values, task_args=tuple(), task_kwargs={},  # pylint: disable=W0102\n                 num_processes=CPU_COUNT):\n    \"\"\"\n    Parallel execution of a mapping of `values` to the function `task`. This\n    is functionally equivalent to::\n\n        result = [task(value, *task_args, **task_kwargs) for value in values]\n\n    On Windows this function defaults to a serial implementation to avoid the\n    overhead from spawning processes in Windows.\n\n    Args:\n        task (func): Function that is to be called for each value in ``task_vec``.\n        values (array_like): List or array of values for which the ``task``\n                            function is to be evaluated.\n        task_args (list): Optional additional arguments to the ``task`` function.\n        task_kwargs (dict): Optional additional keyword argument to the ``task`` function.\n        num_processes (int): Number of processes to spawn.\n\n    Returns:\n        result: The result list contains the value of\n                ``task(value, *task_args, **task_kwargs)`` for\n                    each value in ``values``.\n\n    Raises:\n        QISKitError: If user interrupts via keyboard.\n\n    Events:\n        terra.transpiler.parallel.start: The collection of parallel tasks are about to start.\n        terra.transpiler.parallel.update: One of the parallel task has finished.\n        terra.transpiler.parallel.finish: All the parallel tasks have finished.\n    \"\"\"\n    Publisher().publish(\"terra.transpiler.parallel.start\", len(values))\n    if len(values) == 1:\n        Publisher().publish(\"terra.transpiler.parallel.finish\")\n        return [task(values[0], *task_args, **task_kwargs)]\n\n    nfinished = [0]\n\n    def _callback(_):\n        nfinished[0] += 1\n        Publisher().publish(\"terra.transpiler.parallel.done\", nfinished[0])\n\n    # Run in parallel if not Win and not in parallel already\n    if platform.system() != 'Windows' and num_processes > 1 \\\n       and os.getenv('QISKIT_IN_PARALLEL') == 'FALSE':\n        os.environ['QISKIT_IN_PARALLEL'] = 'TRUE'\n        try:\n            pool = Pool(processes=num_processes)\n\n            async_res = [pool.apply_async(task, (value,) + task_args, task_kwargs,\n                                          _callback) for value in values]\n\n            while not all([item.ready() for item in async_res]):\n                for item in async_res:\n                    item.wait(timeout=0.1)\n\n            pool.terminate()\n            pool.join()\n\n        except KeyboardInterrupt:\n            pool.terminate()\n            pool.join()\n            Publisher().publish(\"terra.parallel.parallel.finish\")\n            raise QISKitError('Keyboard interrupt in parallel_map.')\n\n        Publisher().publish(\"terra.transpiler.parallel.finish\")\n        os.environ['QISKIT_IN_PARALLEL'] = 'FALSE'\n        return [ar.get() for ar in async_res]\n\n    # Cannot do parallel on Windows , if another parallel_map is running in parallel,\n    # or len(values) == 1.\n    results = []\n    for _, value in enumerate(values):\n        result = task(value, *task_args, **task_kwargs)\n        results.append(result)\n        _callback(0)\n    Publisher().publish(\"terra.transpiler.parallel.finish\")\n    return results\n", "path": "qiskit/transpiler/_parallel.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright 2018, IBM.\n#\n# This source code is licensed under the Apache License, Version 2.0 found in\n# the LICENSE.txt file in the root directory of this source tree.\n\n# This file is part of QuTiP: Quantum Toolbox in Python.\n#\n#    Copyright (c) 2011 and later, Paul D. Nation and Robert J. Johansson.\n#    All rights reserved.\n#\n#    Redistribution and use in source and binary forms, with or without\n#    modification, are permitted provided that the following conditions are\n#    met:\n#\n#    1. Redistributions of source code must retain the above copyright notice,\n#       this list of conditions and the following disclaimer.\n#\n#    2. Redistributions in binary form must reproduce the above copyright\n#       notice, this list of conditions and the following disclaimer in the\n#       documentation and/or other materials provided with the distribution.\n#\n#    3. Neither the name of the QuTiP: Quantum Toolbox in Python nor the names\n#       of its contributors may be used to endorse or promote products derived\n#       from this software without specific prior written permission.\n#\n#    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n#    \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n#    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n#    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n#    HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n#    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n#    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n#    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n#    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n#    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n#    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n###############################################################################\n\n\"\"\"\nRoutines for running Python functions in parallel using process pools\nfrom the multiprocessing library.\n\"\"\"\n\nimport os\nimport platform\nfrom multiprocessing import Pool\nfrom qiskit._qiskiterror import QISKitError\nfrom qiskit._util import local_hardware_info\nfrom qiskit._pubsub import Publisher\n\n# Number of local physical cpus\nCPU_COUNT = local_hardware_info()['cpus']\n\n\ndef parallel_map(task, values, task_args=tuple(), task_kwargs={},  # pylint: disable=W0102\n                 num_processes=CPU_COUNT):\n    \"\"\"\n    Parallel execution of a mapping of `values` to the function `task`. This\n    is functionally equivalent to::\n\n        result = [task(value, *task_args, **task_kwargs) for value in values]\n\n    On Windows this function defaults to a serial implementation to avoid the\n    overhead from spawning processes in Windows.\n\n    Args:\n        task (func): Function that is to be called for each value in ``task_vec``.\n        values (array_like): List or array of values for which the ``task``\n                            function is to be evaluated.\n        task_args (list): Optional additional arguments to the ``task`` function.\n        task_kwargs (dict): Optional additional keyword argument to the ``task`` function.\n        num_processes (int): Number of processes to spawn.\n\n    Returns:\n        result: The result list contains the value of\n                ``task(value, *task_args, **task_kwargs)`` for\n                    each value in ``values``.\n\n    Raises:\n        QISKitError: If user interrupts via keyboard.\n\n    Events:\n        terra.transpiler.parallel.start: The collection of parallel tasks are about to start.\n        terra.transpiler.parallel.update: One of the parallel task has finished.\n        terra.transpiler.parallel.finish: All the parallel tasks have finished.\n    \"\"\"\n    if len(values) == 1:\n        return [task(values[0], *task_args, **task_kwargs)]\n\n    Publisher().publish(\"terra.transpiler.parallel.start\", len(values))\n    nfinished = [0]\n\n    def _callback(_):\n        nfinished[0] += 1\n        Publisher().publish(\"terra.transpiler.parallel.done\", nfinished[0])\n\n    # Run in parallel if not Win and not in parallel already\n    if platform.system() != 'Windows' and num_processes > 1 \\\n       and os.getenv('QISKIT_IN_PARALLEL') == 'FALSE':\n        os.environ['QISKIT_IN_PARALLEL'] = 'TRUE'\n        try:\n            pool = Pool(processes=num_processes)\n\n            async_res = [pool.apply_async(task, (value,) + task_args, task_kwargs,\n                                          _callback) for value in values]\n\n            while not all([item.ready() for item in async_res]):\n                for item in async_res:\n                    item.wait(timeout=0.1)\n\n            pool.terminate()\n            pool.join()\n\n        except KeyboardInterrupt:\n            pool.terminate()\n            pool.join()\n            Publisher().publish(\"terra.parallel.parallel.finish\")\n            raise QISKitError('Keyboard interrupt in parallel_map.')\n\n        Publisher().publish(\"terra.transpiler.parallel.finish\")\n        os.environ['QISKIT_IN_PARALLEL'] = 'FALSE'\n        return [ar.get() for ar in async_res]\n\n    # Cannot do parallel on Windows , if another parallel_map is running in parallel,\n    # or len(values) == 1.\n    results = []\n    for _, value in enumerate(values):\n        result = task(value, *task_args, **task_kwargs)\n        results.append(result)\n        _callback(0)\n    Publisher().publish(\"terra.transpiler.parallel.finish\")\n    return results\n", "path": "qiskit/transpiler/_parallel.py"}]}