Hi Yuriy,

(2) cannot be done in Python without major changes in semantics.  User
code that makes no use of threads, for example, certainly doesn't
expect to be careful about multithreading in the __del__ methods.

(1) is hard too.  What is hard is to decide when acquiring a lock in a
__del__ is safe or not.  For example, it would not be safe if the lock
is some global lock.  But it would be safe if the lock belongs to the
object being finalized, in which case (we can hope that) nobody else
can see it any more.

We can't even be sure that an actual deadlock situation encountered in
a __del__ is really a deadlock; maybe a different thread will come
along and release that lock soon...  I think this is a problem that is
just as hard as the general deadlock problem (i.e. unsolvable, but the
user can use some tools to help him figure out deadlocks when they
really happen).


A bientôt,

Armin.
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to