[Python-bugs-list] [ python-Bugs-221327 ] threads within an embedded python interpreter
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 04 Aug 2002 02:47:34 -0700
Bugs item #221327, was opened at 2000-11-03 21:31
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=221327&group_id=5470
Category: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: threads within an embedded python interpreter
Initial Comment:
I have an application which I am required to embedd a python interpreter inside of a C++ application. The python script creates a separate thread of control to handle a TCP/IP socket connection. The thread can send data just find but hangs on the socket 'recv' fnction.
After a dya of debugging my code I went into the python socketmodule.c and at line 1082 I commented out the thread protection code:
/*Py_BEGIN_ALLOW_THREADS*/
n = recv(s->sock_fd, PyString_AsString(buf), len, flags);
/*Py_END_ALLOW_THREADS*/
I then recompiled the python library and then recompiled my C++ app and everything worked just fine.
The problem does not exist when I run the script alone using the python interpreter. Only when I embedd the interpreter, so this is some sort of configuration issue.
David Schere
Email: david_schere@yahoo.com
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2002-08-04 11:47
Message:
Logged In: YES
user_id=21627
Doc/api/init.tex already has a paragraph about calling
Python from a C thread; this patch adds a cookbook example.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-03-01 23:58
Message:
Logged In: YES
user_id=6380
but is it a doco bug or not?
----------------------------------------------------------------------
Comment By: Jeremy Hylton (jhylton)
Date: 2002-03-01 23:34
Message:
Logged In: YES
user_id=31392
Probably ought to fix this for 2.3
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2001-08-31 21:57
Message:
Logged In: NO
Now u pay,.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2000-11-03 21:44
Message:
Most likely, the problem is not the socket module but how you call Python code from a thread that was started from C/C++. Look at t_bootstrap() in threadmodule.c for an example on what to do. (And yes, it's tricky.) There should also be something in the Python/C API documentation about this.
I'm not closing the bug report since this is really a documentation issue; it needs to be documented better. I'll assign it to Fred.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=221327&group_id=5470