Do not use _thread for multithreading

This commit is contained in:
Miguel Grinberg
2022-08-07 15:20:14 +01:00
parent 5054813dc8
commit 998c197058

View File

@@ -27,21 +27,12 @@ try: # pragma: no cover
# use the threading module
threading.Thread(target=f, args=args, kwargs=kwargs).start()
except ImportError: # pragma: no cover
try:
import _thread
def create_thread(f, *args, **kwargs):
# no threads available, call function synchronously
f(*args, **kwargs)
def create_thread(f, *args, **kwargs):
# use MicroPython's _thread module
def run():
f(*args, **kwargs)
concurrency_mode = 'sync'
_thread.start_new_thread(run, ())
except ImportError:
def create_thread(f, *args, **kwargs):
# no threads available, call function synchronously
f(*args, **kwargs)
concurrency_mode = 'sync'
try:
import ujson as json
except ImportError: