Skip to content

Commit c5fd11e

Browse files
committed
Correct indentation
1 parent 7cc3f86 commit c5fd11e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Doc/library/threadsafety.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ atomic. For example:
111111
112112
# NOT atomic: check-then-act
113113
if lst:
114-
item = lst.pop()
114+
item = lst.pop()
115115
116116
# NOT thread-safe: iteration while modifying
117117
for item in lst:
118-
process(item) # another thread may modify lst
118+
process(item) # another thread may modify lst
119119
120120
Consider external synchronization when sharing :class:`list` instances
121121
across threads.
@@ -227,11 +227,11 @@ atomic:
227227
228228
# NOT atomic: check-then-act (TOCTOU)
229229
if key in d:
230-
del d[key]
230+
del d[key]
231231
232232
# NOT thread-safe: iteration while modifying
233233
for key, value in d.items():
234-
process(key) # another thread may modify d
234+
process(key) # another thread may modify d
235235
236236
To avoid time-of-check to time-of-use (TOCTOU) issues, use atomic
237237
operations or handle exceptions:
@@ -244,9 +244,9 @@ operations or handle exceptions:
244244
245245
# Or handle the exception
246246
try:
247-
del d[key]
247+
del d[key]
248248
except KeyError:
249-
pass
249+
pass
250250
251251
To safely iterate over a dictionary that may be modified by another
252252
thread, iterate over a copy:
@@ -256,7 +256,7 @@ thread, iterate over a copy:
256256
257257
# Make a copy to iterate safely
258258
for key, value in d.copy().items():
259-
process(key)
259+
process(key)
260260
261261
Consider external synchronization when sharing :class:`dict` instances
262262
across threads.

0 commit comments

Comments
 (0)