diff --git a/weboob/backends/dlfp/backend.py b/weboob/backends/dlfp/backend.py index 908f9ea8..81223e4d 100644 --- a/weboob/backends/dlfp/backend.py +++ b/weboob/backends/dlfp/backend.py @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +from __future__ import with_statement + from weboob.backend import BaseBackend from weboob.tools.browser import BrowserUnavailable from weboob.capabilities.messages import ICapMessages, ICapMessagesReply, Message @@ -72,7 +74,8 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesReply): new = False try: - thread = self.browser.get_content(article.id) + with self.browser: + thread = self.browser.get_content(article.id) except BrowserUnavailable: continue @@ -111,4 +114,5 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesReply): self.storage.save() def post_reply(self, thread_id, reply_id, title, message): - return self.browser.post_reply(thread_id, reply_id, title, message) + with self.browser: + return self.browser.post_reply(thread_id, reply_id, title, message) diff --git a/weboob/backends/fourchan/backend.py b/weboob/backends/fourchan/backend.py index 4702f16b..9e23cb3a 100644 --- a/weboob/backends/fourchan/backend.py +++ b/weboob/backends/fourchan/backend.py @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +from __future__ import with_statement + from logging import warning from weboob.backend import BaseBackend @@ -60,7 +62,9 @@ class FourChanBackend(BaseBackend, ICapMessages): for message in self._iter_thread_messages(board, thread_wanted, only_new): yield message else: - for thread in self.browser.get_threads(board): + with self.browser: + threads = self.browser.get_threads(board) + for thread in threads: for message in self._iter_thread_messages(board, thread.id, only_new): yield message