-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -514,9 +514,7 @@ async def apply( | |
kwargs: Same as Queue.enqueue | ||
""" | ||
results = await self.map(job_or_func, timeout=timeout, iter_kwargs=[kwargs]) | ||
if results: | ||
return results[0] | ||
return None | ||
return results[0] if results else None | ||
|
||
async def map( | ||
self, | ||
|
@@ -569,10 +567,7 @@ async def callback(job_key: str, status: Status) -> bool: | |
if status in UNSUCCESSFUL_TERMINAL_STATUSES and not return_exceptions: | ||
return True | ||
|
||
if not pending_job_keys: | ||
return True | ||
|
||
return False | ||
return not pending_job_keys | ||
Comment on lines
-572
to
+570
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
# Start listening before we enqueue the jobs. | ||
# This ensures we don't miss any updates. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,8 +111,7 @@ async def _get_job(request: Request) -> Job: | |
async def exceptions(request: Request, handler: Handler) -> StreamResponse: | ||
if request.path.startswith("/api"): | ||
try: | ||
resp = await handler(request) | ||
return resp | ||
return await handler(request) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
except Exception: | ||
error = traceback.format_exc() | ||
logging.error(error) | ||
|
@@ -127,9 +126,7 @@ async def shutdown(app: Application) -> None: | |
|
||
def create_app(queues: list[Queue]) -> Application: | ||
middlewares = [exceptions] | ||
password = os.environ.get("AUTH_PASSWORD") | ||
|
||
if password: | ||
if password := os.environ.get("AUTH_PASSWORD"): | ||
Comment on lines
-130
to
+129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
from aiohttp_basicauth import BasicAuthMiddleware # type:ignore[import] | ||
|
||
user = os.environ.get("AUTH_USER", "admin") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -342,7 +342,7 @@ async def shutdown(_app: Application) -> None: | |
|
||
async def async_check_health(queue: Queue) -> int: | ||
info = await queue.info() | ||
if not info.get("name") == queue.name: | ||
if info.get("name") != queue.name: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
logger.warning("Health check failed") | ||
status = 1 | ||
else: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,9 +41,7 @@ async def test_queues(self) -> None: | |
async with self.client.get("/api/queues") as resp: | ||
self.assertEqual(resp.status, 200) | ||
json = await resp.json() | ||
self.assertEqual( | ||
set(q["name"] for q in json["queues"]), {"queue1", "queue2"} | ||
) | ||
self.assertEqual({q["name"] for q in json["queues"]}, {"queue1", "queue2"}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
async with self.client.get(f"/api/queues/{self.queue1.name}") as resp: | ||
self.assertEqual(resp.status, 200) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
Queue.apply
refactored with the following changes:reintroduce-else
)assign-if-exp
)