Merge lp:~cjwatson/launchpadlib/timeout-eventually into lp:launchpadlib

Proposed by Colin Watson
Status: Merged
Merged at revision: 143
Proposed branch: lp:~cjwatson/launchpadlib/timeout-eventually
Merge into: lp:launchpadlib
Diff against target: 39 lines (+9/-0)
1 file modified
src/launchpadlib/credentials.py (+9/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpadlib/timeout-eventually
Reviewer Review Type Date Requested Status
Dimitri John Ledkov Approve
Review via email: mp+264417@code.launchpad.net

Commit message

Time out make_end_user_authorize_token after 15 minutes.

Description of the change

Time out make_end_user_authorize_token after 15 minutes.

This should at least slightly mitigate issues with misconfigured server jobs that never give up.

To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/launchpadlib/credentials.py'
--- src/launchpadlib/credentials.py 2014-11-08 12:26:25 +0000
+++ src/launchpadlib/credentials.py 2015-07-10 13:38:50 +0000
@@ -82,6 +82,7 @@
82access_token_page = '+access-token'82access_token_page = '+access-token'
83authorize_token_page = '+authorize-token'83authorize_token_page = '+authorize-token'
84access_token_poll_time = 184access_token_poll_time = 1
85access_token_poll_timeout = 15 * 60
8586
86EXPLOSIVE_ERRORS = (MemoryError, KeyboardInterrupt, SystemExit)87EXPLOSIVE_ERRORS = (MemoryError, KeyboardInterrupt, SystemExit)
8788
@@ -651,6 +652,7 @@
651 self.output(self.WAITING_FOR_LAUNCHPAD)652 self.output(self.WAITING_FOR_LAUNCHPAD)
652 if browser is not None:653 if browser is not None:
653 webbrowser.open(authorization_url)654 webbrowser.open(authorization_url)
655 start_time = time.time()
654 while credentials.access_token is None:656 while credentials.access_token is None:
655 time.sleep(access_token_poll_time)657 time.sleep(access_token_poll_time)
656 try:658 try:
@@ -669,6 +671,9 @@
669 # There was an error accessing the server.671 # There was an error accessing the server.
670 print("Unexpected response from Launchpad:")672 print("Unexpected response from Launchpad:")
671 print(e)673 print(e)
674 if time.time() >= start_time + access_token_poll_timeout:
675 raise TokenAuthorizationTimedOut(
676 "Timed out after %d seconds." % access_token_poll_timeout)
672677
673678
674class TokenAuthorizationException(Exception):679class TokenAuthorizationException(Exception):
@@ -683,6 +688,10 @@
683 pass688 pass
684689
685690
691class TokenAuthorizationTimedOut(TokenAuthorizationException):
692 pass
693
694
686class ClientError(TokenAuthorizationException):695class ClientError(TokenAuthorizationException):
687 pass696 pass
688697

Subscribers

People subscribed via source and target branches