Skip to content

Question on locking strategy #8

Description

@tonb

Hi folks,

I'm looking at bakebit_nanohat_oled.py, and despite being very new to python, it seems to me that the lock that is attempted to make sure the draw code is not re-entrant, is broken.

`

lock.acquire()
is_drawing = drawing
page_index = pageIndex
lock.release()

if is_drawing:
    return

lock.acquire()
drawing = True
lock.release()

`

Two threads can easily reach the if statement, then both will proceed to set drawing=True. What am I missing? Cheers!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions