pycom-micropython-sigfox: `utimeq` is not available by default in the standard library

Two other users plus myself are reporting this in detail on the forum.

utimeq is required by uasyncio, a very useful module for creating event loops, available in the «standard» MicroPython library.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Hello, Uasyncio support added in development release 1.19.0.b4. utimeq is part of the firmware since the mentioned version, 1.15.0.b1 thus closing this issue.

Well I have to say, robert-hh is the man. I tested his changes and I’m able to get various parts (uasyncio,core, uasyncio.synchro and uasyncio.queues) of uasyncio working on my WiPy 2.0 running 1.11.0b1.

Regarding the part about replacing ipoll with poll. I read in the MP uasyncio source/uselect docs that they were using ipoll for the oneshot behaviour and that this was equivalent to calling poll.modify(obj, 0) on socks/streams/whatever who have received events. I made the following tiny change to the wait function in https://github.com/micropython/micropython-lib/blob/master/uasyncio/uasyncio/__init__.py to try and reproduce the one-shot behaviour with poll. Did I call self.poller.modify(sock, 0) in a sane place? Sorry I don’t have a great test case (in fact I have no sockets or other stream-type-things) for this at the moment in my codebase.

    def wait(self, delay):
        if DEBUG and __debug__:
            log.debug("poll.wait(%d)", delay)
 
        # change to work with pycom-sigfox-micropython        
        # since we don't have ipoll's one-shot behaviour
        # we have to reset the event mask on any sock
        # that receives an event
        res = self.poller.poll(delay)

        #log.debug("poll result: %s", res)
        # Remove "if res" workaround after
        # https://github.com/micropython/micropython/issues/2716 fixed.
        if res:
            for sock, ev in res:

                # as mentioned above we reset the event mask 
                # manually on each sock that's received an
                # event, i guess this is the right place to do this?
                self.poller.modify(sock, 0)

                cb = self.objmap[id(sock)]
                if ev & (select.POLLHUP | select.POLLERR):
                    # These events are returned even if not requested, and
                    # are sticky, i.e. will be returned again and again.
                    # If the caller doesn't do proper error handling and
                    # unregister this sock, we'll busy-loop on it, so we
                    # as well can unregister it now "just in case".
                    self.remove_reader(sock)
                if DEBUG and __debug__:
                    log.debug("Calling IO callback: %r", cb)
                if isinstance(cb, tuple):
                    cb[0](*cb[1])
                else:
                    cb.pend_throw(None)
                    self.call_soon(cb)