Skip to content
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

async util: handle empty dirs better #3797

Merged
merged 3 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cylc/flow/async_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ def _scandir(future, path, request):
"""Callback helper for scandir()."""
future.set_result([
Path(path, directory.name)
for directory in request.result
# request.result can be None (maybe because of an empty directory in cylc-run)
for directory in request.result or []
Copy link
Member

@hjoliver hjoliver Sep 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this make any difference? If I put an empty directory in ~cylc-run then request.result is an empty list already. (And I didn't see an error without this change).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw an error where (request.result was returning None) in the log whilst working on cylc-uiserver so put this in to suppress it.

Perhaps it happens when you scan a non-existent directory or something like that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, fair enough. Probably needs a comment then, because it looks weird (if you expect request.result to always be list).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, GitHub let me create a "suggestion" and commit it to the branch 😁

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One review will do for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant, my comment was a style violation (line too long) 🤣

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hot fix coming.

])


Expand Down
3 changes: 2 additions & 1 deletion cylc/flow/network/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
SERVICE = Path(SuiteFiles.Service.DIRNAME)
CONTACT = Path(SuiteFiles.Service.CONTACT)
SUITERC = Path(SuiteFiles.SUITE_RC)
FLOW_FILE = Path(SuiteFiles.FLOW_FILE)


def dir_is_flow(listing):
Expand All @@ -95,7 +96,7 @@ def dir_is_flow(listing):
return (
SERVICE.name in listing
or SUITERC.name in listing # cylc7 flow definition file name
or 'flow.cylc' in listing # cylc8 flow definition file name
or FLOW_FILE in listing # cylc8 flow definition file name
or 'log' in listing
)

Expand Down