Skip to content
Shihao Qi
Projects
Writing
Notes
Search
About
中
TAG
Concurrency
Everything filed under this tag.
1 entries
01
Notes
json.dump iterates while it writes: save outside the lock and you get “dictionary changed size during iteration”, save inside and every writer waits
2026-10-16
json.dump(data, f) doesn’t serialize first and then write; it uses the pure-Python encoder and writes while iterating, so serialization and disk I/O can’t be separated. Inside a lock, writers wait as long as the disk takes; outside, any concurrent change to the dict raises RuntimeError. Autarkia’s memory save went back and forth between the two.
#Python
#Concurrency
← All tags
Search the site