> On Apr 30, 2020, at 10:44 AM, Carl Meyer <c...@oddbird.net> wrote:
> 
> On Wed, Apr 29, 2020 at 9:36 PM Raymond Hettinger
> <raymond.hettin...@gmail.com> wrote:
>> Do you have some concrete examples we could look at?   I'm having trouble 
>> visualizing any real use cases and none have been presented so far.
> 
> This pattern occurs not infrequently in our Django server codebase at
> Instagram. A typical case would be that we need a client object to
> make queries to some external service, queries using the client can be
> made from various locations in the codebase (and new ones could be
> added any time), but there is noticeable overhead to the creation of
> the client (e.g. perhaps it does network work at creation to figure
> out which remote host can service the needed functionality) and so
> having multiple client objects for the same remote service existing in
> the same process is waste.
> 
> Or another similar case might be creation of a "client" object for
> querying a large on-disk data set.

Thanks for the concrete example.  AFAICT, it doesn't require (and probably 
shouldn't have) a lock to be held for the duration of the call.  Would it be 
fair to say the 100% of your needs would be met if we just added this to the 
functools module?

      call_once = lru_cache(maxsize=None)

That's discoverable, already works, has no risk of deadlock, would work with 
multiple argument functions, has instrumentation, and has the ability to clear 
or reset.

I'm still looking for an example that actually requires a lock to be held for a 
long duration.


Raymond

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/Y3I646QBI7ICASP62ATFBUPROZ2J4TKE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to