Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
tweepy
Commits
981a4698
Commit
981a4698
authored
Apr 18, 2014
by
Aaron Hill
Browse files
Always expose remaining calls and reset time
parent
e3ff8868
Changes
1
Hide whitespace changes
Inline
Side-by-side
tweepy/binder.py
View file @
981a4698
...
...
@@ -168,17 +168,16 @@ def bind_api(**config):
except
Exception
as
e
:
raise
TweepError
(
'Failed to send request: %s'
%
e
)
if
self
.
wait_on_rate_limit
:
rem_calls
=
resp
.
getheader
(
'x-rate-limit-remaining'
)
if
rem_calls
is
not
None
:
self
.
_remaining_calls
=
int
(
rem_calls
)
elif
isinstance
(
self
.
_remaining_calls
,
int
):
self
.
_remaining_calls
-=
1
reset_time
=
resp
.
getheader
(
'x-rate-limit-reset'
)
if
reset_time
is
not
None
:
self
.
_reset_time
=
int
(
reset_time
)
if
rem_calls
==
0
and
(
resp
.
status
==
429
or
resp
.
status
==
420
):
# if ran out of calls before waiting switching retry last call
continue
rem_calls
=
resp
.
getheader
(
'x-rate-limit-remaining'
)
if
rem_calls
is
not
None
:
self
.
_remaining_calls
=
int
(
rem_calls
)
elif
isinstance
(
self
.
_remaining_calls
,
int
):
self
.
_remaining_calls
-=
1
reset_time
=
resp
.
getheader
(
'x-rate-limit-reset'
)
if
reset_time
is
not
None
:
self
.
_reset_time
=
int
(
reset_time
)
if
self
.
wait_on_rate_limit
and
rem_calls
==
0
and
(
resp
.
status
==
429
or
resp
.
status
==
420
):
# if ran out of calls before waiting switching retry last call
continue
retry_delay
=
self
.
retry_delay
# Exit request loop if non-retry error code
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment