Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle session timeout (on read protected wikis) #158

Open
danmichaelo opened this issue May 10, 2017 · 4 comments
Open

Handle session timeout (on read protected wikis) #158

danmichaelo opened this issue May 10, 2017 · 4 comments
Milestone

Comments

@danmichaelo
Copy link
Member

danmichaelo commented May 10, 2017

From #155 by @Ubibene:

I can login, and then immediatly get page content, save page content , etc. But : I 'm using scripts that run for a long time , scanning all wiki pages, and then modifying page contents : sometimes I'm getting readapidenied error again on my private wiki. For example when trying to save a page :

Traceback (most recent call last):

  File "build/bdist.linux-x86_64/egg/mwclient/page.py", line 216, in save
  File "build/bdist.linux-x86_64/egg/mwclient/page.py", line 121, in get_token
  File "build/bdist.linux-x86_64/egg/mwclient/client.py", line 514, in get_token
  File "build/bdist.linux-x86_64/egg/mwclient/client.py", line 239, in post
  File "build/bdist.linux-x86_64/egg/mwclient/client.py", line 282, in api
  File "build/bdist.linux-x86_64/egg/mwclient/client.py", line 306, in handle_api_result
mwclient.errors.APIError: (u'readapidenied', u'You need read permission to use this module', u'See http://l203psj002.mousquetaires.com/api.php for API usage')

([…] The same happens when making other API calls.)

OK, I guess the following is happening, and may happen with MW < 1.27 too :

  • open a session with mwclient on a private wiki
  • if the session is destroyed on the server and mwclient is making an api call, mwclient calls site.get_token() (which calls action=query&meta=tokens)
  • on a private wiki this raises a readapidenied error as the only api call that can be made when unauthenticated is for getting a logintoken (action=query&meta=tokens&type=login)

I guess we could catch readapidenied in handle_api_result, re-login and retry the request. Just have to be a bit careful to avoid ending up in endless loops :)

@PierreSelim
Copy link
Contributor

I Agree that there should probably be a maximum retry within a given period of time.

@danmichaelo danmichaelo changed the title Handle session timeout on read protected wikis Handle session timeout (on read protected wikis) May 10, 2017
@danmichaelo
Copy link
Member Author

I guess this is not strictly limited to read protected wikis, but could also be an issue with other wikis having short session timeouts?

@ghost
Copy link

ghost commented May 11, 2017

I guess so.

@danmichaelo danmichaelo added this to the 0.9.1 milestone Jun 28, 2018
@audiodude
Copy link

I'm having a problem related to this, which I describe in openzim/wp1#69. Although I have attempted to catch the mwclient.errors.AssertUserFailedError and login again, that doesn't seem to be working. Any help is greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants