[Python.NET] Python 2.4 hang when calling .NET dll function
I have been able to successfully use my .NET DLL (written in C#) using python 2.4 and the Python for .NET DLLs. I basically have one python module implementing a class that is using methods from my C# DLLs. My test application (singlethreaded) ran great, but when integrating the python module that uses the .NET DLLs in a multithreaded program, one call to a .NET function just hangs. All threads are hanging, and I get no response using CTRL+C. I have debugged my application using ntsd, and I do not see any bad behaviour from my called DLLs. Are there some issues with locking/unlocking mechanism when calling functions from .NET DLLs ? Regards Torgeir _ Python.NET mailing list - [email protected] http://mail.python.org/mailman/listinfo/pythondotnet
Re: [Python.NET] Python 2.4 hang when calling .NET dll function
Torgeir Johansen a écrit : >I have been able to successfully use my .NET DLL (written in C#) using >python 2.4 and the Python for .NET DLLs. I basically have one python module >implementing a class that is using methods from my C# DLLs. > >My test application (singlethreaded) ran great, but when integrating the >python module that uses the .NET DLLs in a multithreaded program, one call >to a .NET function just hangs. All threads are hanging, and I get no >response using CTRL+C. > >I have debugged my application using ntsd, and I do not see any bad >behaviour from my called DLLs. Are there some issues with locking/unlocking >mechanism when calling functions from .NET DLLs ? > > Yes there are...And I don't know if they are due to interaction between python and .net, or only to python. I submitted a bug recently on python.org: http://sourceforge.net/tracker/index.php?func=detail&aid=1169108&group_id=5470&atid=105470 >Regards Torgeir > >_ >Python.NET mailing list - [email protected] >http://mail.python.org/mailman/listinfo/pythondotnet > > > > _ Python.NET mailing list - [email protected] http://mail.python.org/mailman/listinfo/pythondotnet
RE: [Python.NET] Python 2.4 hang when calling .NET dll function
> >My test application (singlethreaded) ran great, but when integrating the > >python module that uses the .NET DLLs in a multithreaded > program, one call > >to a .NET function just hangs. All threads are hanging, and I get no > >response using CTRL+C. > > > >I have debugged my application using ntsd, and I do not see any bad > >behaviour from my called DLLs. Are there some issues with > locking/unlocking > >mechanism when calling functions from .NET DLLs ? > > > > > > Yes there are...And I don't know if they are due to interaction between > python and .net, or only to python. There is definitely a problem in the way the bridge is handling the GIL (global interpreter lock) in multithreaded situations. I'm working right now on a beta 5 that re-vamps the GIL handling and hopefully takes care of these issues. > I submitted a bug recently on python.org: > > http://sourceforge.net/tracker/index.php?func=detail&aid=1169108&g roup_id=5470&atid=105470 Note that this is the Python bug tracker -- this issue is specific to Python for .NET, not the core CPython so it would be best to use the tracker at http://www.zope.org/Members/Brian/PythonNet/Collector/ Brian Lloyd[EMAIL PROTECTED] V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com _ Python.NET mailing list - [email protected] http://mail.python.org/mailman/listinfo/pythondotnet
[Python.NET] Python 2.4 hang when calling .NET dll function
Great, Brian. I successfully reproduced the state with a very simple application. Here is very dumb python program that uses the CLR: from CLR.System import String class cSharpCaller( object ): def __init__( self ): print "Created a cSharpCaller instance" self.__cSharpString = None def createCSharpString( self, str ): self.__cSharpString = String( str ) def returnCSharpString( self ): return self.__cSharpString.ToString() And if I test this with this (dumb) threethreaded testprogram: import threading, thread, time from cSharpCaller import cSharpCaller def start_threads(amount=5): for i in range(amount): thread = threading.Thread(target=process_thread ) print "starting thread ", thread.getName() thread.start() def process_thread( ): print "thread started " for i in range( 2 ): print "Hi, I'm a thread" time.sleep( 1 ) cs = cSharpCaller( ) cs.createCSharpString( "created from a thread" ) print "cs.returnCSharpString() = ", cs.returnCSharpString() print "thread %s ended" start_threads( 3 ) I get this output: starting thread thread0thread startedHi, I'm thread %sstarting thread thread1thread startedHi, I'm thread %sstarting thread thread2thread startedHi, I'm thread %sHi, I'm thread %sHi, I'm thread %sHi, I'm thread %sCreated a cSharpCaller instanceCreated a cSharpCaller instancecs.returnCSharpString() = and I have to CTRL+Pause to get out of the hang. Clearly hangs on the first String.ToString() method call. Regards, Torgeir _ Python.NET mailing list - [email protected] http://mail.python.org/mailman/listinfo/pythondotnet
