[Python-Dev] Re: Adding a scarier warning to object.__del__?

2020-01-04 Thread Andrew Svetlov
On Sat, Jan 4, 2020 at 5:43 AM Inada Naoki wrote: > > I don't want to recommend atexit or weakref because they have their pitfall. > > I think the context manager should be considered at first when people want > to use __del__. > I support this proposal :) > -- > Inada Naoki >

[Python-Dev] Re: Adding a scarier warning to object.__del__?

2020-01-04 Thread Antoine Pitrou
On Wed, 1 Jan 2020 11:51:41 -0800 "Gregory P. Smith" wrote: > On Wed, Jan 1, 2020 at 6:40 AM Andrew Svetlov > wrote: > > > __del__ is very useful not for interpreter shutdown but as a regular > > destructor in object's lifecycle. > > > > The reason we should warn people against ever implement

[Python-Dev] Re: Adding a scarier warning to object.__del__?

2020-01-04 Thread Greg Ewing
On 5/01/20 11:41 am, Antoine Pitrou wrote: +1 for pointing to `weakref.finalize` as a better alternative for things that may survive until interpreter shutdown. I'm not sure that weakref.finalize is much better. It can still be called at an arbitrary time from an arbitrary thread with the rest

[Python-Dev] Re: Adding a scarier warning to object.__del__?

2020-01-04 Thread Nick Coghlan
On Fri., 3 Jan. 2020, 3:52 am Yonatan Zunger, wrote: > weakref.finalize always executes during the ordinary Python flow, IIUC -- > e.g., it happens before the interpreter is stopping. I guess it does still > have the "arbitrary thread" limitation -- which is a good point, I may have > some code b