Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pokecli.py: wait_time for every exception randomized #5704

Merged
merged 2 commits into from
Nov 9, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import subprocess

from logging import Formatter
from random import randint

codecs.register(lambda name: codecs.lookup("utf-8") if name == "cp65001" else None)

Expand Down Expand Up @@ -185,7 +186,7 @@ def get_commit_hash():
finished = False

while not finished:
wait_time = config.reconnecting_timeout * 60
wait_time = randint(config.reconnecting_timeout, (config.reconnecting_timeout * 60))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs adjustment and docs changes: previously, config.reconnecting_timeout was "time in minutes". Now the wait_time spans from this valud to the 60-times of it.

Maybe randint(config.reconnecting_timeout*60, (config.reconnecting_timeout + 1) * 60)) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an other possibility is to extend the config file with min and max entries, which I think is a overkill for that.

maybe only an random variation of the given time, something like 'randint((config.reconnecting_timeout * 0.8 * 60, config.reconnecting_timeout * 1.2 * 60))'
40% vast/span/range...

also, I don't find any documentation about it, but I thought that I saw an entry once.

try:
bot = initialize(config)
bot = start_bot(bot, config)
Expand Down Expand Up @@ -241,9 +242,10 @@ def get_commit_hash():
'api_error',
sender=bot,
level='info',
formatted='Server is throttling, reconnecting in 30 seconds'
formatted='Server is throttling, reconnecting in {:d} seconds'.format(wait_time)
)
time.sleep(30)
time.sleep(wait_time)
# sys.exit()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be removed

except PermaBannedException:
bot.event_manager.emit(
'api_error',
Expand Down