brianr at liffe.com wrote in <vt1yqzvb68.fsf at liffe.com>: >In a similar vein, would the following work? : > >class Guard: <snip> No it wouldn't work. The reason is that if no exception is thrown the guard variable will be deleted when g goes out of scope, i.e. when the function returns, but if an exception is thrown a traceback object is created which maintains a reference to all the local variables including g. If this happens the lock will not be released until the traceback is destroyed which will not happen until another exception is thrown, and possibly not even then. I think that even if no exception is thrown this won't work under Jython either as it (if my memory serves) depends on garbage collection to clean up objects.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4