
March 30, 2011
4 a.m.
On Wed, Mar 30, 2011 at 5:32 AM, Sturla Molden <sturla@molden.no> wrote:
from contextlib import contextmanager import ctypes _Py_Ticker = ctypes.c_int.in_dll(ctypes.pythonapi,"_Py_Ticker")
@contextmanager def atomic(): tmp = _Py_Ticker.value _Py_Ticker.value = 0x7fffffff yield _Py_Ticker.value = tmp - 1
Yikes, at least stick a try-finally in there! If you must practice evil, practice safe evil ;) Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia