os_listdir: This can be long-running, run background tasks

While finding sources of clicks and buzzes in nrf i2sout, I identified
this site as one which could be long running.  Reproducer code was to
play a 22.05kHz sample and repeatedly print `os.listdir('')`
This commit is contained in:
jepler 2019-09-09 20:04:08 -05:00
parent d9c8460934
commit 676f7aa808

View File

@ -128,6 +128,7 @@ mp_obj_t common_hal_os_listdir(const char* path) {
while ((next = mp_iternext(iter_obj)) != MP_OBJ_STOP_ITERATION) {
// next[0] is the filename.
mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL));
RUN_BACKGROUND_TASKS;
}
return dir_list;
}