~/talk

Tackling Thread Safety in Python

Talkat PiterPy 2024 · 2024-09-18..09-27· [python, concurrency]
slides:none on file

A simple booking example runs 15 concurrent tasks against 10 seats and ends with available_seats at -5 when using ThreadPoolExecutor because of race conditions; wrapping the critical section with a mutex via lock.acquire/release fixes overselling. A recursive nested-acquire deadlock becomes safe with an RLock. A Semaphore initialized to 3 limits concurrent bookings to three, an Event signals “flight landed” to waiting threads, a Barrier waits for five participants before proceeding, and a Condition implements a producer–consumer customer queue.

AI-written summary · about

  1. 0:00Introduction to thread safety
  2. 2:21Speaker introduction and agenda
  3. 3:04Why use threading in Python
  4. 6:40Race conditions in shared data
  5. 7:23Context switching demonstration
  6. 10:18What is thread safety
  7. 11:46Options for thread-safe code
  8. 13:11Using locks for thread safety
  9. 16:24Reentrant locks explained
  10. 19:43Semaphores for limiting access
  11. 22:54Events for thread signaling
  12. 25:48Barriers for thread coordination
  13. 30:04Conditions for producer-consumer
  14. 38:37Key considerations for thread safety
  15. 40:23Q&A session
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 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
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
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.