Skip to content

Commit

Permalink
Merge pull request #7420 from readthedocs/humitos/duplicate-builds-wi…
Browse files Browse the repository at this point in the history
…thin-window-time
  • Loading branch information
humitos authored Sep 7, 2020
2 parents 470b2e8 + 950010a commit 25ae9ca
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions readthedocs/core/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""Common utilty functions."""

import datetime
import errno
import logging
import os
import re

from celery import chord, group
from django.conf import settings
from django.utils import timezone
from django.utils.functional import keep_lazy
from django.utils.safestring import SafeText, mark_safe
from django.utils.text import slugify as slugify_base
Expand Down Expand Up @@ -184,6 +186,13 @@ def prepare_build(
project=project,
version=version,
state=BUILD_STATE_TRIGGERED,
# By filtering for builds triggered in the previous 5 minutes we
# avoid false positives for builds that failed for any reason and
# didn't update their state, ending up on blocked builds for that
# version (all the builds are marked as DUPLICATED in that case).
# Adding this date condition, we reduce the risk of hitting this
# problem to 5 minutes only.
date__gte=timezone.now() - datetime.timedelta(minutes=5),
).count() > 1

if not project.has_feature(Feature.DEDUPLICATE_BUILDS):
Expand Down

0 comments on commit 25ae9ca

Please sign in to comment.