Threading question .. am I doing this right?

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Feb 24 23:59:23 EST 2022


On 25/02/22 1:08 am, Robert Latest wrote:
> My question is: Is this a solid approach? Am I forgetting something?

I can see a few of problems:

* 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.

* 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).

* The caller of get_data() is getting an object that could
be changed under it by a future update.

-- 
Greg


More information about the Python-list mailing list