Threading question .. am I doing this right?
Robert Latest
boblatest at yahoo.com
Fri Feb 25 12:19:32 EST 2022
Greg Ewing wrote:
> * If more than one thread calls get_data() during the initial
> cache filling, it looks like only one of them will wait for
> the thread -- the others will skip waiting altogether and
> immediately return None.
Right. But that needs to be dealt with somehow. No data is no data.
> * Also if the first call to get_data() times out it will
> return None (although maybe that's acceptable if the caller
> is expecting it).
Right. Needs to be dealt with.
> * The caller of get_data() is getting an object that could
> be changed under it by a future update.
I don't think that's a problem. If it turns out to be one I'll create a copy of
the data while I hold the lock and pass that back.
>
More information about the Python-list
mailing list