lock on Browser (snif)
This commit is contained in:
parent
8b822dcd09
commit
2650c32b24
1 changed files with 8 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ import re
|
||||||
import time
|
import time
|
||||||
from logging import warning, error, debug
|
from logging import warning, error, debug
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
from threading import RLock
|
||||||
|
|
||||||
from weboob.tools.parsers import get_parser
|
from weboob.tools.parsers import get_parser
|
||||||
|
|
||||||
|
|
@ -160,12 +161,19 @@ class BaseBrowser(mechanize.Browser):
|
||||||
self.last_update = 0.0
|
self.last_update = 0.0
|
||||||
self.username = username
|
self.username = username
|
||||||
self.password = password
|
self.password = password
|
||||||
|
self.lock = RLock()
|
||||||
if self.password:
|
if self.password:
|
||||||
try:
|
try:
|
||||||
self.home()
|
self.home()
|
||||||
except BrowserUnavailable:
|
except BrowserUnavailable:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
self.lock.acquire()
|
||||||
|
|
||||||
|
def __exit__(self, t, v, tb):
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
def pageaccess(func):
|
def pageaccess(func):
|
||||||
def inner(self, *args, **kwargs):
|
def inner(self, *args, **kwargs):
|
||||||
if not self.page or self.password and not self.page.is_logged():
|
if not self.page or self.password and not self.page.is_logged():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue