Visitar URL original
Merge branch 'develop' into import-export · RocketMap/RocketMap@7844410 · GitHub
Skip to content

Commit 7844410

Browse files
author
Ditto-IV100
committed
Merge branch 'develop' into import-export
1 parent b81bb26 commit 7844410

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎pogom/pgorequestwrapper.py‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,22 @@ def call(self, *args, **kwargs):
5555
log.debug('Sending wrapped API request.')
5656
return self.request.call(*args, **kwargs)
5757
except HashingQuotaExceededException:
58+
# Default = sleep for a little bit, then retry.
59+
random_sleep_secs = random.uniform(0.75, 1.5)
60+
secs_to_sleep = random_sleep_secs
61+
5862
# Sleep until the RPM reset to free some RPM and don't use
5963
# one of our retries, just retry until we have RPM left.
6064
# If RPM reset was in the past, we'll still sleep for a
6165
# little bit to introduce variation.
62-
now = int(time.time())
63-
rpm_reset = HashServer.status.get('period', now)
64-
secs_till_reset = rpm_reset - now
65-
random_sleep_secs = random.uniform(0.75, 1.5)
66-
secs_to_sleep = random_sleep_secs
67-
68-
# Could be outdated key header, or already passed.
69-
if secs_till_reset > 0:
70-
secs_to_sleep = secs_till_reset + random_sleep_secs
66+
if self.args.hash_header_sleep:
67+
now = int(time.time())
68+
rpm_reset = HashServer.status.get('period', now)
69+
secs_till_reset = rpm_reset - now
70+
71+
# Could be outdated key header, or already passed.
72+
if secs_till_reset > 0:
73+
secs_to_sleep = secs_till_reset + random_sleep_secs
7174

7275
# Don't be too enthusiastic about sleeping. Failsafe against a
7376
# bugged header, timezone problems, ...

‎pogom/utils.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,11 @@ def get_args():
491491
help=('Hash service name. Supports bossland and'
492492
' devkat hashing.'),
493493
choices=['bossland', 'devkat'])
494+
parser.add_argument('--hash-header-sleep',
495+
help=('Use the BossLand headers to determine how long'
496+
' a worker should sleep if it exceeds the'
497+
' hashing quota. Default: False.'),
498+
action='store_true', default=False)
494499
parser.add_argument('-novc', '--no-version-check', action='store_true',
495500
help='Disable API version check.',
496501
default=False)

0 commit comments

Comments
 (0)