Earlier quoted context omitted.
I think it says if your async code holds locks you’re gonna have a bad time. Async and optimistic locks probably should go hand in hand. I would think finalizers and async code magnify problems that are already there.
If you use a single-threaded executor then you don't need locks in your async code. Well, you might use external locks, but not thread synchronization primitives. When I write async code I use a single-threaded multi-process pattern. Look ma'! No locks! Well, that's not very fair. The best async code I've written was embarrassingly parallel, no-sync-needed, read-only stuff. If I was writing an RDBMS I would very much…
Async and Finaliser Deadlocks
11–20 of 22 posts
Re: Async and Finaliser Deadlocks
#12Re: Async and Finaliser Deadlocks
#13Earlier quoted context omitted.
I think it says if your async code holds locks you’re gonna have a bad time. Async and optimistic locks probably should go hand in hand. I would think finalizers and async code magnify problems that are already there.
If you use a single-threaded executor then you don't need locks in your async code. Well, you might use external locks, but not thread synchronization primitives. When I write async code I use a single-threaded multi-process pattern. Look ma'! No locks! Well, that's not very fair. The best async code I've written was embarrassingly parallel, no-sync-needed, read-only stuff. If I was writing an RDBMS I would very much…
Re: Async and Finaliser Deadlocks
#14 def close(self):
self._closed = True
self.do_interesting_finalisation_stuff()
def __del__(self):
if not self._closed:
print("Programming error! Forgot to .close()", self)
If you do anything the slightest bit more interesting than that in your __del__, then you are likely to regret it.Every time I've written a __del__ that did more, it has been trouble and I've ended up whittling it down to a simple diagnostic. With one notable exception: A __del__ that put a termination notification into a queue.Queue which a different thread was listening to. That one worked great: If the other thread was still alive and listening, then it would get the message. If not, then the message would just get garbage-collected with the Queue, but message would be redundant anyway, so that would be fine.
Re: Async and Finaliser Deadlocks
#15Re: Async and Finaliser Deadlocks
#16A __del__ that does any kind of real work is asking for trouble. Use it to print a diagnostic reminding you to call .close() or .join() or use a with statement, and nothing else. For example: def close(self): self._closed = True self.do_interesting_finalisation_stuff() def __del__(self): if not self._closed: print("Programming error! Forgot to .close()", self) If you do anything the slightest bit more interesting tha…
Re: Async and Finaliser Deadlocks
#17Did anyone assure that this code is using a recursive mutex???
Because, well, lol, a second lock on a non-recursive mutex would look like what is reported here.
KISS and gn8
Re: Async and Finaliser Deadlocks
#18Before drawing any „higher order conclusion“ … Did anyone assure that this code is using a recursive mutex??? Because, well, lol, a second lock on a non-recursive mutex would look like what is reported here. KISS and gn8
Everyone is free to overcompensate, remunerate, juxtapose, aggravate, frustrate, vandalize, …
Re: Async and Finaliser Deadlocks
#19A __del__ that does any kind of real work is asking for trouble. Use it to print a diagnostic reminding you to call .close() or .join() or use a with statement, and nothing else. For example: def close(self): self._closed = True self.do_interesting_finalisation_stuff() def __del__(self): if not self._closed: print("Programming error! Forgot to .close()", self) If you do anything the slightest bit more interesting tha…
You can't call inappropriate functions if you don't have any way to reach them!