technique:python:bash_multithreading

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
technique:python:bash_multithreading [2021/05/29 22:23] – créée francoisatechnique:python:bash_multithreading [2024/04/02 15:08] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
-====== Python, bash et Multithreading ====== +**Cette page est obsolèteVeuillez accéder au contenu à son nouvel emplacement [[https://bibliotech.cemea.org/books/outils-technique/page/bash-multithreading|bash-multithreading]]**
- +
-===== Script bash ===== +
- +
-Lancer un script bash avec nice 19 (faible priorité): +
- +
-<code python> +
-from subprocess import Popen +
- +
-resultat = Popen(["nice -n 19 bash nomduscript.sh"], shell = True) +
-resultat.wait() +
- +
-if resultat.returncode == 0: +
-    print("Succes"+
- +
-</code> +
-===== Tâche de fond ===== +
- +
-Cas de processus en tâche de fond et qui redonne la main au fil principal +
- +
-<code> +
-from multiprocessing import Process +
- +
-def tache_en_fond(mes_vars): +
-    # Fait des trucs en tâche de fond +
- +
-if __name__ == '__main__': +
-    p = Process(target=tache_en_fond, args=(mes_vars),daemon=True) +
-    p.start() +
-    print("On continue le fil"+
- +
-</code> +
- +
-===== Multithreading ===== +
- +
-Le multithreading impose de décomposer plusieurs tâches dans plusieurs threads +
- +
-https://pythonguides.com/python-threading-and-multithreading/ +
- +
-https://docs.python.org/3/library/threading.html +
- +
-https://www.tutorialspoint.com/python/python_multithreading.htm +
- +
  • technique/python/bash_multithreading.1622319804.txt.gz
  • Dernière modification : 2021/05/29 22:23
  • de francoisa