[Python.NET] AcquireThreadLock - bug? future?
brian at zope.com
Mon Mar 14 13:07:31 CET 2005
Essentially the engine needs to own the thread lock in
order to call Python C API functions. When a (managed)
method is called, the MethodBinder:
- releases the lock (so that other threads could
- calls the managed method
- re-acquires the lock after the call (because it
needs to use the C API again to Pythonify the
So it sounds like some thread is unable to re-acquire
the lock. This gets tricky _really_ quickly, because
you can actually be calling a managed object that may
later call back into Python code... etc.
Note that this doesn't happen for properties, because I
arbitrarily decided that since properties are expected to
to be lightweight that it wasn't worth the overhead ;)
Brian Lloyd brian at zope.com
V.P. Engineering 540.361.1716
Zope Corporation http://www.zope.com
> -----Original Message-----
> From: pythondotnet-bounces at python.org
> [mailto:pythondotnet-bounces at python.org]On Behalf Of Roman Yakovenko
> Sent: Monday, March 14, 2005 1:24 AM
> To: pythondotnet at python.org
> Subject: [Python.NET] AcquireThreadLock - bug? future?
> Hi. I have small problem with multithreading and need help to solve it.
> I have dll written in managed C++. Within dll I have class that has
> static function. I'd like to call this function from a few threads
> from python. I failed to do this. Calling function staled and this is
> a stack dump from debugger ( of my program )
> + 0x40 bytes
> python.runtime.dll!Python.Runtime.MethodBinder.Invoke(int inst =
> 11793552, int args = 9900080, int kw = 0) + 0xf0 bytes
> python.runtime.dll!Python.Runtime.MethodObject.Invoke(int target =
> 11793552, int args = 9900080, int kw = 0) + 0x25 bytes
> python.runtime.dll!Python.Runtime.MethodBinding.tp_call(int ob =
> 11794928, int args = 9900080, int kw = 0) + 0x137 bytes
> I don't understand:
> 1. Why Python.Net tries to acquire thread lock, while calling
> function ?
> I am possible to call get property from a few threads. From
> managed C++ point of view ( I could be wrong here ) getting value of
> property it is just syntax sugaring for get_??? call. I want to say
> that if I able to call "get property" from a few threads I should be
> able to call function from a few threads.
> 2. Why at all Python.Net tries to synchronize function calls?
> I can modify and compile source code of Python.Net, but I know to
> little about reasons
> of calling AcquireThreadLock.
> Thanks for help
> Python.NET mailing list - PythonDotNet at python.org
More information about the PythonDotNet