self.results = {}
- def check(self, *domains, batch_size=10240):
+ async def check(self, *domains, batch_size=10240):
"""
Checks all domains that need checking.
"""
while True:
# Submit some more domains for checking unless we have been given
# some by the caller.
- for domain in domains:
+ async for domain in domains:
self.submit(domain)
# Break when we have submitted enough domains
try:
for result in concurrent.futures.as_completed(self.results, timeout=1):
- self._store(result)
+ await self._store(result)
# If nothing has completed, we just start a new iteration
except TimeoutError:
pass
# Manually commit after a batch has been processed
- self.backend.db.commit()
+ await self.backend.db.commit()
# Update all stats after we checked all domains
- for source in self.backend.sources:
- source.update_stats()
+ async for source in self.backend.sources:
+ await source.update_stats()
# Update all stats for all lists
- for list in self.backend.lists:
- list.update_stats()
+ async for list in self.backend.lists:
+ await list.update_stats()
def get_domains(self, limit=None):
"""
return result
- def _store(self, result):
+ async def _store(self, result):
"""
Called after we have received a result for the queried domain
"""
)
# Store the result
- self.backend.db.execute(stmt)
+ await self.backend.db.execute(stmt)
list_id : int = sqlmodel.Field(foreign_key="lists.id", exclude=True)
# List
- list : "List" = sqlmodel.Relationship(back_populates="sources")
+ list : "List" = sqlmodel.Relationship(
+ back_populates="sources", sa_relationship_kwargs={ "lazy" : "selectin" },
+ )
# Last Modified At
last_modified_at : datetime.datetime | None = sqlmodel.Field(exclude=True)
updated_at : datetime.datetime | None
# Domains
- domains : "Domain" = sqlmodel.Relationship(back_populates="source")
+ domains: "Domain" = sqlmodel.Relationship(back_populates="source")
# Delete!