Skip to content

missing uasyncio libraries #197

Description

@lila

my understanding is that the current version of circuit python (v1.0) is based on micropython 1.8.7. micropython (i think) does support uasyncio and has a external libraries project called micropython-lib that holds a number of librariies including the uasyncio library (there are two there, one is uasyncio which is empty and uasyncio.core which is what i want).

i guess my question is: how can i build/download a compatible version of uasyncio.core for use with circuitpython v1.0?

i can package the contents of uasyncio.core and copy it to circuitpython's lib folder, but when i try to define an async function, it generates a syntax error. for example:

async def pwm_cycle(led, duty, cycles):

The error is:

File "code.py", line 6
SyntaxError: invalid syntax

any pointers are appreciated...

thanks,

  • k

Activity

  1. lila commented on Aug 20, 2017

    @lila
    Author

    just more details:

    it appears that the async keyword is new in python starting at version 3.5. circuiltpython v1.0 is using python version 3.4.0.

    import sys
    print(sys.version_info)
    (3, 4, 0)

    but 3.4 does have coroutines, using @asyncio.coroutine instead of async. however,

    import asyncio
    Traceback (most recent call last):
    File "", line 1, in
    ImportError: no module named 'asyncio'

    • k
  2. tannewt commented on Aug 21, 2017

    @tannewt
    Member

    What board are you trying this on? I'd expect it to work on ESP8266.

  3. lila commented on Aug 21, 2017

    @lila
    Author
  4. tannewt commented on Aug 21, 2017

    @tannewt
    Member

    Ok, I've not taken any time to look into adding it. What libraries are you trying to use on top of it?

  5. willingc commented on Aug 21, 2017

    @willingc

    @lila The async stuff in MicroPython and its additional libraries is a subset of CPython and still looks a bit work in progress. What's your use case for the module?

  6. lila commented on Aug 21, 2017

    @lila
    Author

    i'd like to use libraries such as : https://github.com/peterhinch/micropython-async in order to do event driven programming of the board. For example, when buttons are pressed or accelleratometers triggered do run a coroutine, rather than have to explicitly poll for each of the inputs.

    in https://github.com/peterhinch/micropython-async/blob/master/aswitch.py there is a pushbutton class that handles the registration and execution of the python functions.

    i find that's a much easier way to program...

    if there are other ways to do this, please let me know... thanks,

    • k
  7. tannewt commented on Aug 21, 2017

    @tannewt
    Member

    I think async programming is much harder to teach than sync programming so this is very low on my list.

    If you or anyone else are interested in adding support, please reopen for tracking. Otherwise, I'm closing this. While I think we'll get there eventually, there are just too many other things to do including additional MCU support, standardizing APIs and networking to consider this in the medium term.

  8. sethcohn commented on Aug 21, 2017

    @sethcohn

    The micropython uasyncio code is very actively being worked on, as in a commit that is only a day old (as of now), by pfalcon. Until it's reasonably stable, I can't see that it's gonna get much attention for the limited number of ports (samd, esp8266) that adafruit folks are trying to get into a manageable shape. (and keep in mind, CP doesn't track MP exactly, there are some differences such as using non-micro libraries (random vs urandom, for one example...))

  9. ronysh commented on Mar 4, 2018

    @ronysh

    I totally agree that event driven input can bring working with these boards to the next level.

  10. tannewt commented on Mar 5, 2018

    @tannewt
    Member

    @ronysh please follow #619 for more info.

  11. rosstie commented on Jun 3, 2022

    @rosstie

    So just to clarify asyncio is not currently supported on Circuit Playground Express? I have been trying to work this out as I would like to utilize cooperative multitasking.

  12. dhalbert commented on Jun 3, 2022

    @dhalbert
    Collaborator

    @rosstie That's right, there just isn't room for it in the firmware space we have (256kB, which includes several frozen libraries).

  13. ladyada commented on Jun 3, 2022

    @ladyada
    Member

    you could try the circuit playground bluefruit instead! it has a ton of flash/ram :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions