Quellcode durchsuchen

sleep to avoid busy waiting.

jrobinAV vor 1 Jahr
Ursprung
Commit
fdf4779575
1 geänderte Dateien mit 3 neuen und 0 gelöschten Zeilen
  1. 3 0
      taipy/core/_orchestrator/_dispatcher/_job_dispatcher.py

+ 3 - 0
taipy/core/_orchestrator/_dispatcher/_job_dispatcher.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 
 import threading
+import time
 from abc import abstractmethod
 from queue import Empty
 from typing import Dict, Optional
@@ -69,6 +70,8 @@ class _JobDispatcher(threading.Thread):
                             break
                         job = self.orchestrator.jobs_to_run.get(block=True, timeout=0.1)
                     self._execute_job(job)
+                else:
+                    time.sleep(0.1)  # We need to sleep to avoid busy waiting.
             except Empty:  # In case the last job of the queue has been removed.
                 pass
             except Exception as e: