Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
technique:python:bash_multithreading [2021/05/29 22:23] – créée francoisa | technique: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ète. Veuillez accéder |
- | + | ||
- | ===== Script bash ===== | + | |
- | + | ||
- | Lancer un script bash avec nice 19 (faible priorité): | + | |
- | + | ||
- | <code python> | + | |
- | from subprocess import Popen | + | |
- | + | ||
- | resultat = Popen([" | + | |
- | resultat.wait() | + | |
- | + | ||
- | if resultat.returncode == 0: | + | |
- | print(" | + | |
- | + | ||
- | </ | + | |
- | ===== Tâche de fond ===== | + | |
- | + | ||
- | Cas de processus en tâche de fond et qui redonne la main au fil principal | + | |
- | + | ||
- | < | + | |
- | from multiprocessing import Process | + | |
- | + | ||
- | def tache_en_fond(mes_vars): | + | |
- | # Fait des trucs en tâche de fond | + | |
- | + | ||
- | if __name__ == ' | + | |
- | p = Process(target=tache_en_fond, | + | |
- | p.start() | + | |
- | print(" | + | |
- | + | ||
- | </ | + | |
- | + | ||
- | ===== Multithreading ===== | + | |
- | + | ||
- | Le multithreading impose de décomposer plusieurs tâches dans plusieurs threads | + | |
- | + | ||
- | https://pythonguides.com/ | + | |
- | + | ||
- | https:// | + | |
- | + | ||
- | https:// | + | |
- | + |