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:
parent
18f2e94846
commit
97fd18a7e2
1 changed files with 8 additions and 0 deletions
|
|
@ -33,6 +33,14 @@ def thread_main():
|
|||
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.
|
||||
lock = _thread.allocate_lock()
|
||||
lock.acquire()
|
||||
|
|
|
|||
Loading…
Reference in a new issue