Created
January 3, 2022 06:13
-
-
Save Cyan101/2a097b5278b7bc133f9671d52e7fdaf2 to your computer and use it in GitHub Desktop.
Testing threading on micropython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import machine | |
import utime | |
import _thread | |
def threadStart(x): | |
while True: | |
print(f"Thread {x} here!") | |
utime.sleep(1) | |
_thread.start_new_thread(threadStart(1), ()) | |
print("ayyy") | |
print("lmao") |
maybe due to repl being on one core?
seems it doesnt like having the functions args in like that, and even if one arg is being passed it must be in a tuple, example working below:
import machine
import utime
import _thread
def threadStart(x):
print("\nyo")
utime.sleep(2)
print("ayy")
_thread.start_new_thread(threadStart, (1,))
print("hey")
utime.sleep(3)
print("gg")
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my thread runs but the follow text/code does not, this is for the pico which has 2 cores and trying to get dual threads running