Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| python:async [2018/12/05 11:40] – créée: threads, locks phsw | python:async [2021/04/04 17:01] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | ====== Programmation asynchrone ====== | + | ====== Programmation asynchrone |
| - | ===== Threads | + | ------- |
| + | ==== Threads ==== | ||
| - | ==== Lancement de threads | + | === Lancement de threads === |
| <code python> | <code python> | ||
| Ligne 31: | Ligne 32: | ||
| - | ==== Verrous | + | === Verrous === |
| <code python> | <code python> | ||
| Ligne 42: | Ligne 43: | ||
| with verrou: | with verrou: | ||
| # section critique | # section critique | ||
| - | </ | + | </ |
| + | |||
| + | |||
| + | |||
| + | ------ | ||
| + | |||
| + | ==== Paralléliser un map ==== | ||
| + | |||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | <code python> | ||
| + | import multiprocessing | ||
| + | from functools import partial | ||
| + | |||
| + | |||
| + | def loop_function(j, | ||
| + | # ... | ||
| + | |||
| + | with multiprocessing.Pool(5) as p: | ||
| + | raw_hist = p.map(partial(loop_function, | ||
| + | </ | ||
| + | |||
| + | La fonction '' | ||