Replies: 3 comments 7 replies
-
So I guess you would either need to grab the MicroPython GIL or preallocate an int array to use here. |
Beta Was this translation helpful? Give feedback.
-
I did just give this a try and get the same crash during tuple creation. |
Beta Was this translation helpful? Give feedback.
-
@bwhitman Without pre-allocating, the only way to solve this is to run the Python callback synchronously. This is what we do with Bluetooth on ESP32. Right now this is not generic and is very tied to the Bluetooth implementation (search for @dlech @glenn20 Acquiring the GIL on its own is not sufficient because the GC's allocator access thread state. We are looking at making this a generic function -- i.e. "run_on_micropython_thread" that provides a similar API to |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using
mp_sched_schedule
to call a Python user callback in C code for Tulip. . The c code necessarily happens in a different thread (and on hardware, ESP FreeRTOS task). I want to pass two integers to the users' callback. I'm finding that sending one value in the callback works fine, like:The user can write
But i want to send two values.
mp_sched_schedule
only allows one argument. So I tried making a tuple in the C code:This crashes when creating the tuple with
Presumably, trying to access the MP GC from another thread is bad. (But i'm unsure why doing a single
mp_obj_new_int
works reliably.)Anyway, I want to send two values from C to a Python function from another thread. What can i do?
Beta Was this translation helpful? Give feedback.
All reactions