On 12 Mar 2006 17:56:37 -0800, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > >Thinking about future directions for Python threading, I wonder if >there is a way to expose the GIL (or simply impose a temporary >moratorium on thread switches) so that it becomes easy to introduce >atomicity when needed: > > gil.acquire(BLOCK=True) > try: > #do some transaction that needs to be atomic > finally: > gil.release() >
This is vaguely possible using sys.setcheckinterval() now, although one has to pick a ridiculously large number and hope that the atomic operation takes fewer than that many opcodes. Spelling "do not switch threads" as sys.setcheckinterval(None) seems somewhat natural, though. Perhaps that would be a fruitful direction to explore. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list