_thread limitation on stmhal ports

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
ajie_dirgantara
Posts: 73
Joined: Fri Sep 02, 2016 9:26 am

_thread limitation on stmhal ports

Post by ajie_dirgantara » Tue Oct 17, 2017 9:27 am

I am using stmhal port, and been using _thread module. Is the thread creation limited at 8 threads only?
because when I try to start 9th thread it raise MemoryError exception :

Code: Select all

Traceback (most recent call last):
  File "main.py", line 221, in <module>
  File "main.py", line 219, in main
  File "main.py", line 204, in mainModeNormal
MemoryError: memory allocation failed, allocating 4096 bytes

User avatar
pythoncoder
Posts: 1963
Joined: Fri Jul 18, 2014 8:01 am

Re: _thread limitation on stmhal ports

Post by pythoncoder » Tue Oct 17, 2017 9:49 am

I think threading is fairly RAM intensive. If you can tolerate cooperative scheduling uasyncio is highly efficient: I have tested with hundreds of coroutines.
Peter Hinch

ajie_dirgantara
Posts: 73
Joined: Fri Sep 02, 2016 9:26 am

Re: _thread limitation on stmhal ports

Post by ajie_dirgantara » Tue Oct 17, 2017 10:36 am

pythoncoder wrote:
Tue Oct 17, 2017 9:49 am
I think threading is fairly RAM intensive. If you can tolerate cooperative scheduling uasyncio is highly efficient: I have tested with hundreds of coroutines.


I'll stick with _thread module for now. But I'll take a look later. Thanks.

Post Reply