# Как предотвратить пересечение задач? DistributedMutex?

**URL:** <https://meta.discourse.org/t/how-to-use-prevent-overlapping-jobs-distributedmutex/130393>\
**Category:** Development\
**Created:** [07.Октябрь.2019 09:23:17 UTC](https://meta.discourse.org/t/how-to-use-prevent-overlapping-jobs-distributedmutex/130393 "2019-10-07T09:23:17Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Mark\_Schmucker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mark_schmucker/32/124810_2.png) [@Mark\_Schmucker](https://meta.discourse.org/u/Mark_Schmucker)\
**Post date:** [07.Октябрь.2019 23:44:36 UTC](https://meta.discourse.org/t/how-to-use-prevent-overlapping-jobs-distributedmutex/130393/3 "2019-10-07T23:44:36Z")

</div>

Я думаю, что делаю то же самое, что и в [https://review.discourse.org/t/feature-allow-post-process-mutex-to-be-held-longer/5017](https://review.discourse.org/t/feature-allow-post-process-mutex-to-be-held-longer/5017) и [https://review.discourse.org/t/fix-post-and-topic-creation-race-condition/5247](https://review.discourse.org/t/fix-post-and-topic-creation-race-condition/5247), за исключением использования фигурных скобок вместо do/end, но, по-моему, это не имеет значения.

DistributedMutex.synchronize(“custom\_digest”, validity: 180.minutes) {  
do\_stuff  
}

Однако do\_stuff выполняется несколько раз одновременно, и это происходит в пределах тех самых 180 минут.

---

_[View the full topic](https://meta.discourse.org/t/how-to-use-prevent-overlapping-jobs-distributedmutex/130393)._
