~/talk

Tackling Thread Safety in Python

Talkat XtremePython 2024 Online Conference · on Tuesday, 2024-11-19· [concurrency, python]
slides:none on file

Demonstrates that naive threading on a shared variable causes a real race: a booking script with 10 seats / 15 customers -> final count -5 because concurrent read/write interleaves. Shows concrete fixes using Python threading: using a Lock fixes to 10 booked; an RLock prevents deadlock for nested acquisitions; a Semaphore example limits concurrent bookings to three (10 workers proceed three at a time). Also covers Event, Barrier, and Condition primitives and when to prefer avoiding shared mutable state.

AI-written summary · about

  1. 0:00Introduction to thread safety
  2. 1:04What is threading in Python
  3. 3:58Understanding race conditions
  4. 7:11Thread safety explained
  5. 9:38Synchronization primitives overview
  6. 10:20Using locks for thread safety
  7. 13:33Re-entrant locks and deadlocks
  8. 17:06Semaphores for resource control
  9. 21:48Event primitives for signaling
  10. 23:11Barriers for thread coordination
  11. 24:57Condition variables explained
  12. 28:34Best practices and summary
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.