diff options
author | Florian Jung <flo@windfisch.org> | 2015-08-21 17:46:14 +0200 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2015-08-21 17:46:14 +0200 |
commit | 83c23f0aebb72359a29dc4dca31be2622acdbcb6 (patch) | |
tree | 85e31f460414a626541ca04d7248e6202d9039c9 /main.py | |
parent | 1abc1581137fe968fb94f89810ac8563afbfd800 (diff) |
automatically retry if connecting fails. agario pls.
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 31 |
1 files changed, 19 insertions, 12 deletions
@@ -18,17 +18,24 @@ sub = DummySubscriber() c = client.Client(sub) stats = stats.Stats() -# find out server and token to connect -try: - token = sys.argv[1] - addr, *_ = utils.get_party_address(token) -except: - addr, token, *_ = utils.find_server() - -# connect -c.connect(addr,token) -c.send_facebook( - 'g2gDYQFtAAAAEKO6L3c8C8/eXtbtbVJDGU5tAAAAUvOo7JuWAVSczT5Aj0eo0CvpeU8ijGzKy/gXBVCxhP5UO+ERH0jWjAo9bU1V7dU0GmwFr+SnzqWohx3qvG8Fg8RHlL17/y9ifVWpYUdweuODb9c=') +for i in range(1,10): # 10 connection attempts + print("trying to connect, attempt "+str(i)) + try: + # find out server and token to connect + try: + token = sys.argv[1] + addr, *_ = utils.get_party_address(token) + except: + addr, token, *_ = utils.find_server() + + # connect + c.connect(addr,token) + c.send_facebook( + 'g2gDYQFtAAAAEKO6L3c8C8/eXtbtbVJDGU5tAAAAUvOo7JuWAVSczT5Aj0eo0CvpeU8ijGzKy/gXBVCxhP5UO+ERH0jWjAo9bU1V7dU0GmwFr+SnzqWohx3qvG8Fg8RHlL17/y9ifVWpYUdweuODb9c=') + break + except: + c.disconnect() + c.player.nick="test cell pls ignore" @@ -53,4 +60,4 @@ while True: stats.log_pos(c.player.center) stats.log_mass(c.player.total_mass) - gui.update()
\ No newline at end of file + gui.update() |