async
parent
ef258f05ad
commit
5db7b20e9f
Binary file not shown.
19
news/pool.py
19
news/pool.py
|
@ -139,7 +139,7 @@ class ArticleRepository:
|
||||||
|
|
||||||
async def fetch_article(self, url: str) -> tuple[str, str]:
|
async def fetch_article(self, url: str) -> tuple[str, str]:
|
||||||
async with self._lock:
|
async with self._lock:
|
||||||
result = await self.get_article(url)
|
result = self._get_article(url)
|
||||||
if result:
|
if result:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -165,15 +165,18 @@ class ArticleRepository:
|
||||||
|
|
||||||
async def get_article(self, url: str) -> tuple[str, str] | None:
|
async def get_article(self, url: str) -> tuple[str, str] | None:
|
||||||
async with self._lock:
|
async with self._lock:
|
||||||
# Single writer at a time when using sqlite3 – avoids `database is locked`
|
return self._get_article(url)
|
||||||
row = self._row_for_url(url)
|
|
||||||
|
|
||||||
if row: # row = (id, url, title, raw, processed)
|
def _get_article(self, url: str) -> tuple[str, str] | None:
|
||||||
LOGGER.info(f"[ArticleRepository] Found cached article for {url}")
|
# Single writer at a time when using sqlite3 – avoids `database is locked`
|
||||||
return row[2], row[4] # processed_html already present
|
row = self._row_for_url(url)
|
||||||
|
|
||||||
LOGGER.info(f"[ArticleRepository] Article was not found for {url}")
|
if row: # row = (id, url, title, raw, processed)
|
||||||
return None
|
LOGGER.info(f"[ArticleRepository] Found cached article for {url}")
|
||||||
|
return row[2], row[4] # processed_html already present
|
||||||
|
|
||||||
|
LOGGER.info(f"[ArticleRepository] Article was not found for {url}")
|
||||||
|
return None
|
||||||
|
|
||||||
async def has_paragraphs(self, url) -> bool:
|
async def has_paragraphs(self, url) -> bool:
|
||||||
async with self._lock:
|
async with self._lock:
|
||||||
|
|
Loading…
Reference in New Issue