[Ironpython-users] Issues with multithreading, ironpython and numpy

Eirik Årdal eirik.ardal at bouvet.no
Fri Oct 18 10:20:47 CEST 2013


First, let me start by saying that I don't have a lot of experience with Iron Python, or Python for that matter, but I know a person involved with the current project who is an experienced Python developer, but is unable to help with this issue since we believe it has to do with our integration between my C# code and his Python code. Also, I am aware that this might not be directly a IronPython issue, but it's certainly involving IronPython, NymPy for .net and C# and integration between them.

The short version of our problem is that when I call his Python scripts through IronPython in a multithreaded context, I get a System.InsufficientMemoryException thrown by NumPyDotNet. However, if I run my code synchronously on one thread, it works fine.

The long version is that I have a Windows Service that constantly checks in a database for new entries that will trigger work to be done (calculating data). I need to be able to do the calculation work on another thread in order to not lock up the service, making it unresponsive. But calling the Python scripts through IronPython on my worker thread results in the exception above. If I run my code on one thread, the service is unresponsive during start-up and windows terminates it after a certain time, saying it could not put it into its "started" state since its locked by work.

I have tried various ways to do my work asynchronous, like starting a Task and using the timers in Microsoft's libraries. I have not tried async/await from .net 4.5 since upgrading to .net 4.5 is not desireable by the project management.

The same problem was explained (not by me) in this stackoverflow post http://stackoverflow.com/questions/10003344/ironpython-version-of-numpy-doesnt-work-in-multi-threaded-environment but there are very few other similar issues when I search forums.

Any suggestions or tips will be greatly appreciated.

Eirik Årdal / 54°24'42" S 3°25'33" E
Bouvet Norge AS, Solheimsgaten 15, NO-5058 Bergen
Mobil +47 992 999 31
http://www.bouvet.no<http://www.bouvet.no/?utm_source=Signatur%2Bno&utm_medium=Epost&utm_campaign=Bouvet%2Bsignatur>   eirik.ardal at bouvet.no<mailto:eirik.ardal at bouvet.no>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20131018/557f83bf/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.jpg
Type: image/jpeg
Size: 1671 bytes
Desc: image003.jpg
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20131018/557f83bf/attachment.jpg>

More information about the Ironpython-users mailing list