Slightly more aggressive implementation of google_dos_protection.

This commit is contained in:
Achim D. Brucker 2017-07-29 11:21:15 +01:00
parent d05ca9678e
commit 0ca3476b09
1 changed files with 8 additions and 6 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
#
# Copyright (C) 2016,2017 The University of Sheffield, UK
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@ -13,16 +13,18 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# along with this program. If not, see <https://www.gnu.org/licenses/>.
""" Various utility methods."""
import sys
from time import sleep
from random import randint
from random import randrange
def google_dos_protection(max=2):
sleep(randint(1, max) * .6)
def google_dos_protection(maxrange=2):
"""Wait a random number of seconds (between 0.5 to maxrange*0.5)
to avoid Google's bot detection"""
sleep(randrange(1, maxrange) * .5)
def log(verbose, msg):