Openmv _thread module support?

In OPENMV2 board, try to utilize the mpy thread functionality. Upset, the function is not working fine. three thread are scheduled by around 10s interval. Code as below:

import pyb
import time
import _thread

def led(id, dt):
    while 1:
        pyb.LED(id).toggle()
        time.sleep(dt)

#led(2, 1000)   
_thread.start_new_thread(led, (1, 1000))
_thread.start_new_thread(led, (2, 1000))
_thread.start_new_thread(led, (3, 1000))

By comparing with pyboard, after enable the _thread module in mpconfiguration.h, the _thread func working well. thread are scheduling as multi-thread working.
in mpconfiguration.h for pyboard

#define MICROPY_PY_THREAD           (1)
#define MICROPY_PY_THREAD_GIL       (1)

Thus, whether there is extra more configuration needed in OpenMV project to enable the thread function?
Kindly waiting for your support

Threading doesn’t work very well with our code, probably due to this bug with pendsv handler:

Hi, it here any plan of the problem fix? that is very upset the thread not work. some porting code need to adapt by this.

Also tested on micropython trunk. mutlithread is working fine. :stuck_out_tongue:

It works in Micropyhton because they don’t use this patch, we use this patch because this bug affects the IDE (causes the camera to crash when the script is started/stopped). There’s No plan to support threading before this issue is fixed in Micropython first.

would you help to highlight the patch. in my work, multithread support is more important than OPENMV IDE works. so I tend to remove that patch temporarily.

Thanks iabdalkader, but after remove this patch, multithread in OPENMV board is still not working fine. is that so, before this patch, openmv can support multthread before? or anything else I missed

Is there any update on this? We would like to run two wifi sockets, one providing only images and another accepting commands to run some connected hardware. We can do that on one socket now by requesting images via a command on that channel between the other channels, but…

There are two different programs that we need to support on the PC side:

  • One program only understands getting a constant stream of image data. We can’t change that program.
  • Our program can send commands and recognize different responses.

We would like to run an thread that only sends images on one port, and have the main thread process commands.

@iabdalkader

Is there an update on this? I have a similar use case as @JamesNewton and would really appreciate it if there’s anything at least experimental with threading. Thanks!