python - Flask app times out nba_py -
i trying make flask app uses python library nba_py. believe library makes web requests pull down nba game data.
for example when have route looks this
@app.route('/games/', methods=['get']) def get_games(): scoreboard = nba_py.scoreboard(month=2, day=21, year=2015) return jsonify({'message': 'test'}) when go route hangs , gives up. i'm not sure going on behind scenes of nba_py have idea why might timing out? routes work on local machine.
your code seems work fine.
you don't have exception raising when problem occurs?
function _get_json() nba_py/__init__.py supposed raise httperror http return code not 200.
just tested did python3 , nba_py 0.1.1a2:
(env) >>> import nba_py (env) >>> score = nba_py.scoreboard(month=2, day=21, year=2015) (env) >>> print(score.available()) [{'game_id': '0021400820', 'pt_available': 1}, {'game_id': '0021400817', 'pt_available': 1}, {'game_id': '0021400819', 'pt_available': 1}, {'game_id': '0021400818', 'pt_available': 1}, {'game_id': '0021400816', 'pt_available': 1}] (env) >>> the thing call scoreboard seems take 1 sec complete doesn't seem disturb flask.
i've tried with:
- flask==0.12.2
- nba-py==0.1.1a2
- python 3.6.1
and works fine.
is firewall (iptables, pf or such) allowing outgoing traffic?
maybe nba site slow/down @ time you've tried or blacklisted ip?
you're right, nba_py module totally sending ougoing http requests (see nba_py/__init__.py instance). can also, when calling api, try print right after scoreboard.json see if json retreived.
to understand what's happening module, due lack of documentation, you'll have add debug messages (why not logging module , pr main github repo debugging purposes).
good luck!
Comments
Post a Comment