[Python.NET] Problems using Python.net in a TurboGears App on ubuntu/mono

Brian Lloyd brian.lloyd at revolutionhealth.com
Tue Apr 1 15:50:34 CEST 2008


Any chance you're on a 64-bit system?

If not, I suspect that the mono runtime is running in STA threading
(which means you can't call it from other threads, generally). If
so, you may be able to find a way to get mono to run in MTA (I don't
know the details of how you would do that though).

sorry-that's-probably-not-too-helpful'ly,

Brian


On 4/1/08 9:19 AM, "Ulrich Eck" <lists at net-labs.de> wrote:

> Hi all,
> 
> i'm trying to use the C#-Library iTextSharp within a TurboGears
> Application.
> 
> the most convenient way would be, to use pythonnet to access the
> needed methods of the c#-library.
> 
> but .. i get a Segfault when trying to use clr imports:
> 
> executed with: "mono python.exe start-netdemo.py"
> 
> --------------------------
> #!/usr/bin/python
> # -*- coding: utf-8 -*-
> """Start script for the netdemo TurboGears project.
> 
> This script is only needed during development for running from the
> project
> directory. When the project is installed, easy_install will create a
> proper start script.
> """
> 
> import clr
> import System
> 
> import sys
> from netdemo.commands import start, ConfigurationError
> 
> if __name__ == "__main__":
>      try:
>          start()
>      except ConfigurationError, exc:
>          sys.stderr.write(str(exc))
>          sys.exit(1)
> ---------------
> 
> 
> the following traceback is produced - can anyone suggest, how to debug
> or find a solution - my expectation is, that there is some trouble
> with threading, but this is just guessing. pythonnet basically works,
> i can import from iTextSharp using the interpreter-cli.
> 
> -----------------
> root at wwdev:/data/develop/test/netdemo# mono python.exe start-netdemo.py
> Stacktrace:
> 
>    at (wrapper managed-to-native)
> Python.Runtime.Runtime.PyInt_FromLong (intptr) <0x00004>
>    at (wrapper managed-to-native)
> Python.Runtime.Runtime.PyInt_FromLong (intptr) <0xffffffff>
>    at Python.Runtime.Runtime.PyInt_FromInt32 (int) <0x0002f>
>    at Python.Runtime.Runtime.Initialize () <0x00234>
>    at Python.Runtime.PythonEngine.Initialize () <0x0002f>
>    at (wrapper runtime-invoke) System.Object.runtime_invoke_void
> (object,intptr,intptr,intptr) <0xffffffff>
> 
> Native stacktrace:
> 
>          /usr/lib/libmono.so.0 [0xb7b096c6]
>          /usr/lib/libmono.so.0 [0xb7adbe96]
>          [0xffffe440]
>          [0xb6f69681]
>          [0xb6f69630]
>          [0xb71e267d]
>          [0xb71dc790]
>          [0xb71dc6f0]
>          /usr/lib/libmono.so.0 [0xb7adbcc6]
>          /usr/lib/libmono.so.0(mono_runtime_invoke+0x33) [0xb7b6f88e]
>          /usr/lib/python2.5/site-packages/clr.so(main_thread_handler
> +0xc6) [0xb7cbde16]
>          /usr/lib/python2.5/site-packages/clr.so(PyNet_Init+0x7f)
> [0xb7cbdf7f]
>          /usr/lib/python2.5/site-packages/clr.so(initclr+0x76)
> [0xb7cbdc46]
>          /usr/bin/python(_PyImport_LoadDynamicModule+0xa4) [0x80e1a34]
>          /usr/bin/python [0x80df6d5]
>          /usr/bin/python [0x80df98b]
>          /usr/bin/python [0x80dfe3e]
>          /usr/bin/python [0x80e0068]
>          /usr/bin/python(PyImport_ImportModuleLevel+0x27) [0x80e04f7]
>          /usr/bin/python [0x80c1db4]
>          /usr/bin/python(PyObject_Call+0x27) [0x805c9e7]
>          /usr/bin/python(PyEval_CallObjectWithKeywords+0x6c) [0x80c232c]
>          /usr/bin/python(PyEval_EvalFrameEx+0x18bd) [0x80c4a9d]
>          /usr/bin/python(PyEval_EvalCodeEx+0x775) [0x80ca115]
>          /usr/bin/python(PyEval_EvalCode+0x57) [0x80ca187]
>          /usr/bin/python(PyRun_FileExFlags+0xf8) [0x80e9698]
>          /usr/bin/python(PyRun_SimpleFileExFlags+0x187) [0x80e9927]
>          /usr/bin/python(Py_Main+0x9c0) [0x8059390]
>          /usr/bin/python(main+0x22) [0x80588c2]
>          /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)
> [0xb7d9f050]
>          /usr/bin/python [0x8058831]
> 
> Debug info from gdb:
> 
> Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
> [Thread debugging using libthread_db enabled]
> [New Thread -1210545984 (LWP 8343)]
> [New Thread -1222792304 (LWP 8345)]
> [New Thread -1222710384 (LWP 8344)]
> 0xffffe410 in __kernel_vsyscall ()
>    3 Thread -1222710384 (LWP 8344)  0xffffe410 in __kernel_vsyscall ()
>    2 Thread -1222792304 (LWP 8345)  0xffffe410 in __kernel_vsyscall ()
>    1 Thread -1210545984 (LWP 8343)  0xffffe410 in __kernel_vsyscall ()
> 
> Thread 3 (Thread -1222710384 (LWP 8344)):
> #0  0xffffe410 in __kernel_vsyscall ()
> #1  0xb7f0d9f6 in ?? () from /lib/tls/i686/cmov/libpthread.so.0
> #2  0xb7bec7db in ?? () from /usr/lib/libmono.so.0
> #3  0xb71ee3cc in ?? ()
> #4  0x00000000 in ?? ()
> 
> Thread 2 (Thread -1222792304 (LWP 8345)):
> #0  0xffffe410 in __kernel_vsyscall ()
> #1  0xb7f0a676 in pthread_cond_wait@@GLIBC_2.3.2 ()
>     from /lib/tls/i686/cmov/libpthread.so.0
> #2  0xb7bf191e in ?? () from /usr/lib/libmono.so.0
> #3  0xb76c81dc in ?? ()
> #4  0xb76c81c4 in ?? ()
> #5  0xb7f08541 in pthread_mutex_lock () from /lib/tls/i686/cmov/
> libpthread.so.0
> #6  0xb7bf1c2b in ?? () from /usr/lib/libmono.so.0
> #7  0xb76c81dc in ?? ()
> #8  0xb76c81c4 in ?? ()
> #9  0x00000000 in ?? ()
> 
> Thread 1 (Thread -1210545984 (LWP 8343)):
> #0  0xffffe410 in __kernel_vsyscall ()
> #1  0xb7e552a1 in select () from /lib/tls/i686/cmov/libc.so.6
> #2  0xb7a36780 in g_spawn_sync () from /usr/lib/libglib-2.0.so.0
> #3  0xb7a36b4c in g_spawn_command_line_sync () from /usr/lib/
> libglib-2.0.so.0
> #4  0xb7b097ad in ?? () from /usr/lib/libmono.so.0
> #5  0xb797f840 in ?? ()
> #6  0xb797f828 in ?? ()
> #7  0xb797f824 in ?? ()
> #8  0xb797f820 in ?? ()
> #9  0x00000000 in ?? ()
> #0  0xffffe410 in __kernel_vsyscall ()
> 
> 
> =================================================================
> Got a SIGSEGV while executing native code. This usually indicates
> a fatal error in the mono runtime or one of the native libraries
> used by your application.
> =================================================================
> 
> 2008-04-01 15:10:11,740 cherrypy.msg INFO ENGINE: SystemExit raised:
> shutting down autoreloader
> 2008-04-01 15:10:11,741 cherrypy.msg INFO HTTP: HTTP Server shut down
> 2008-04-01 15:10:11,746 cherrypy.msg INFO ENGINE: CherryPy shut down
> -----------------
> 
> 
> Do i need to do special things (like pythoncom->CoInitialize) when
> using pythonnet in a multithreaded environment ?
> 
> thanks for all your hints - i'ld try to avoid using python and
> ironpython together with pyro ;-) or worse, code the itext-stuff in c#
> and
> call it from the cmd-line ;-)
> 
> cheers Ulrich
> 
> 
> _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org
> http://mail.python.org/mailman/listinfo/pythondotnet

--------------------------
Brian Lloyd

brian.lloyd at revolutionhealth.com



More information about the PythonDotNet mailing list