[IronPython] Thread Locking
dinov at microsoft.com
Mon Dec 13 19:09:49 CET 2010
Lock is just syntactic sugar for doing Monitor.Enter/Monitor.Exit calls on the object and setting up the try/finally. Here's the IronPython equivalent:
from System.Threading import Monitor
def __init__(self, obj):
self.obj = obj
def __exit__(self, exc_type, exc_value, exc_tb):
(I thought we had considered putting something like this in the clr module at one point in time so you wouldn't have to define the Locker class but it looks like that never made it in but it'd be an easy thing to add if someone wanted to give it a try).
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sam Dozor
Sent: Monday, December 13, 2010 9:18 AM
To: Discussion of IronPython
Subject: [IronPython] Thread Locking
I'm trying to use IronPython to lock a thread and have not been able to import the correct modules. I have IronPython.modules.dll in the same directory as IronPython.dll, and yet when I try the line "import threading" I get something like "threading module does not exist".
I'm basically trying to use the lock() keyword from .NET, but if I can use Python's locking capabilities I'd do that too. Any ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users