What are the semantics of data passed to threading.Thread.__init__()? Are they copied over and made local to the thread? Or, do they continue to be shared with the creating thread? The docs say that args is a tuple, so I assume it will be deep copied, but would like to make sure.
Basically, I’d like to dump a buffer periodically to disk, and I plan to pass this buffer as the arg to a saving thread’s __init__. Can I continue to modifying the buffer in the calling thread without worrying if it will be affected in the saving thread?
Data are generally shared in Python unless you explicitly copy. Dumping a buffer from one thread while modifying it in another is not a safe operation unless the buffer itself has a thread-safe design. You need to synchronise access to the buffer somehow.