-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
Add os.walk wrapper #193
base: main
Are you sure you want to change the base?
Add os.walk wrapper #193
Conversation
Blocked by the PR #192 . Update: not any more. |
84b6491
to
0faf5b5
Compare
#160 (comment) - the |
@Tinche , hello, shall we review this PR, please? |
Apologies. I have a small baby nowadays. So the original sync |
Hello and no need for apologies, au contraire, congratulations. |
@iiSeymour , @alemigo , hello. Could you possibly help with reviewing? |
@Tinche , hello. If you have time, could you assign a reviewer for this PR? Thank you and I wish you splendid holidays. |
statvfs = wrap(os.statvfs) | ||
|
||
|
||
async def walk(top, topdown=True, onerror=None, followlinks=False): |
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.
Ok, better, but this function isn't really async now. It doesn't handle file system operations in a thread, and so can block the event loop, which we're trying to avoid.
Instead of a simple for loop, try executing next()
on the threadpool.
To get you started, maybe try something like
source = os.walk(...)
while True:
f = await loop.run_in_executor(None, next, source)
Addresses the issue #160 .
Features:
wrap
function is placed in thebase.py
module as a basic function of sorts -> importing thewrap
function from theos.py
orospath.py
are not expected to be downos.walk
coroutine