Skip to content
Advertisement

Tag: race-condition

competing regular expressions (race condition)

I’m trying to use python PLY (lex/yacc) to parse a language called ‘GRBL’. GRBL looks something like this: The ‘G’ Codes tell a machine to ‘go’ (or move) and the coordinates say where. LEX requires us to specify a unique regular expression for every possible ‘token’. So in this case I need a regex that will clearly define ‘G00’ and

Atomic increment of a counter in django

I’m trying to atomically increment a simple counter in Django. My code looks like this: If I understand Django correctly, this should wrap the function in a transaction and make the increment atomic. But it doesn’t work and there is a race condition in the counter update. How can this code be made thread-safe? Answer Use an F expression: either

Advertisement