WiPy Timer Multithread

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Posts: 6
Joined: Tue Oct 18, 2016 7:29 pm

WiPy Timer Multithread

Postby iron2414 » Wed Mar 15, 2017 3:34 pm

Hi there, i've been searching for a while now and i haven't found any answer for my question: if i have 2 WiPy timer (let's call them timerA and TimerB for example), and they both tick almost the same time, then will the functions they call executed in parallel way (multithread), or will the second function be delayed until the first one finishes its execution? (like a sequential run)?

Why this is an issue for me: I have a WiPy and one MPU9150 sensor, i wanna read the sensor constantly with TimerA and store the valuable data in files on the WiPy. And With TimerB i wanna search for Wifi connections, and send all the data from the files to a webserver. However TimerB tick might take a while, for example if the files size are more than 1 MB then it could take seconds,maybe minutes until it sends everything to the webserver. And if reading the sensor data stops for this whole time, its a problem for me.

If its not multithreaded is there a way to make something like this happen?

Regards, iron2414

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

Re: WiPy Timer Multithread

Postby pythoncoder » Thu Mar 16, 2017 8:29 am

Perhaps it would be better to discard timer B and have the main loop periodically check for and communicate with a server.
Peter Hinch

Return to “General Discussion and Questions”

Who is online

Users browsing this forum: mahmud, microPyforMy and 3 guests