Micropython WIFI Scan weirdness

Anyone care to offer an explanation why this:

def scan(self):
    wlans = self._sta_if.scan()
    return wlans

works reliably, while this:

    def scan(self):
        return self._sta_if.scan()

fails with OsError EPERM

The second one worked fine before I upgraded to latest firmware. On Plasma 2350 board, btw

TO clarify, I'm really curious and wondering if anyone has any insight.

Could you post the full context? Scanning is asynchronous in the low-level driver. The current MicroPython has a 10 sec wait for scanning to finish, but looking at the source code this seems to be an arbitrary choice.

Could it be that you call both of your different methods in fast succession and the second one fails because the first hasn’t finished yet? What are your results if you reset the device before running each method?