tests/extmod/select_poll_eintr.py: Pre-allocate global variables.
This is a workaround for the case where threading is enabled without a GIL. In such a configuration, creating a new global variable is not atomic and threads have race conditions resizing/accessing the global dict. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -33,6 +33,14 @@ def thread_main():
|
|||||||
print("thread gc end")
|
print("thread gc end")
|
||||||
|
|
||||||
|
|
||||||
|
# Pre-allocate global variables here so the global dict is not resized by the main
|
||||||
|
# thread while the secondary thread runs. This is a workaround for the bug described
|
||||||
|
# in https://github.com/micropython/micropython/pull/11604
|
||||||
|
poller = None
|
||||||
|
t0 = None
|
||||||
|
result = None
|
||||||
|
dt_ms = None
|
||||||
|
|
||||||
# Start a thread to interrupt the main thread during its call to poll.
|
# Start a thread to interrupt the main thread during its call to poll.
|
||||||
lock = _thread.allocate_lock()
|
lock = _thread.allocate_lock()
|
||||||
lock.acquire()
|
lock.acquire()
|
||||||
|
|||||||
Reference in New Issue
Block a user