Skip to content

Commit

Permalink
really optimize the code
Browse files Browse the repository at this point in the history
  • Loading branch information
xmcp committed May 14, 2016
1 parent ddc795f commit 41fd44f
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions wxbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import os
import sys
import traceback
import webbrowser
import pyqrcode
import requests
Expand Down Expand Up @@ -40,17 +39,13 @@ def show_image(file_path):
webbrowser.open(file_path)

class SafeSession(requests.Session):
def request(self, method, url, params=None, data=None, headers=None, cookies=None, files=None, auth=None,
timeout=None, allow_redirects=True, proxies=None, hooks=None, stream=None, verify=None, cert=None,
json=None):
def request(self, *args, **kwargs):
for i in range(3):
try:
return super(SafeSession, self).request(method, url, params, data, headers, cookies, files, auth,
timeout,
allow_redirects, proxies, hooks, stream, verify, cert, json)
except Exception as e:
print e.message,traceback.format_exc()
continue
return super(SafeSession, self).request(*args, **kwargs)
except:
pass
return super(SafeSession, self).request(*args, **kwargs)


class WXBot:
Expand Down

0 comments on commit 41fd44f

Please sign in to comment.