use lock on Browser
This commit is contained in:
parent
2650c32b24
commit
ad240e7aed
2 changed files with 36 additions and 27 deletions
|
|
@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
"""
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
from weboob.backend import BaseBackend
|
||||
from weboob.capabilities.messages import ICapMessages, ICapMessagesReply
|
||||
from weboob.capabilities.dating import ICapDating
|
||||
|
|
@ -67,6 +69,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesReply, ICapDating):
|
|||
yield message
|
||||
|
||||
def _iter_messages(self, thread, only_new):
|
||||
with self.browser:
|
||||
try:
|
||||
if not only_new or self.browser.nb_new_mails():
|
||||
my_name = self.browser.get_my_name()
|
||||
|
|
@ -94,10 +97,12 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesReply, ICapDating):
|
|||
def post_reply(self, thread_id, reply_id, title, message):
|
||||
for message in self._iter_messages(thread_id, True):
|
||||
self.queue_messages.append(message)
|
||||
with self.browser:
|
||||
return self.browser.post(thread_id, message)
|
||||
|
||||
def get_profile(self, _id):
|
||||
try:
|
||||
with self.browser:
|
||||
return self.browser.get_profile(_id)
|
||||
except BrowserUnavailable:
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
"""
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
from logging import debug
|
||||
from random import randint
|
||||
from weboob.tools.browser import BrowserUnavailable
|
||||
|
|
@ -42,6 +44,7 @@ class ProfilesWalker(object):
|
|||
self.event = None
|
||||
|
||||
def walk(self):
|
||||
with self.browser:
|
||||
self.profiles_queue = self.profiles_queue.union(self.browser.search_profiles()).difference(self.visited_profiles)
|
||||
self.save()
|
||||
|
||||
|
|
@ -53,6 +56,7 @@ class ProfilesWalker(object):
|
|||
return # empty queue
|
||||
|
||||
try:
|
||||
with self.browser:
|
||||
profile = self.browser.get_profile(id)
|
||||
debug(u'Visited %s (%s)' % (profile.get_name(), id))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue