homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: threads within an embedded python interpreter
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: loewis Nosy List: akuchling, gvanrossum, jhylton, loewis, nobody
Priority: normal Keywords:

Created on 2000年11月03日 20:31 by anonymous, last changed 2022年04月10日 16:03 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
init.diff loewis, 2002年08月04日 09:47
Messages (8)
msg2325 - (view) Author: Nobody/Anonymous (nobody) Date: 2000年11月03日 20:31
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
msg2326 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2000年11月03日 20:44
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.
msg2327 - (view) Author: Nobody/Anonymous (nobody) Date: 2001年08月31日 19:57
Logged In: NO 
Now u pay,.
msg2328 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2002年03月01日 22:34
Logged In: YES 
user_id=31392
Probably ought to fix this for 2.3
msg2329 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002年03月01日 22:58
Logged In: YES 
user_id=6380
but is it a doco bug or not?
msg2330 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002年08月04日 09:47
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.
msg2331 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2003年02月05日 20:21
Logged In: YES 
user_id=11375
Typo in init.diff: "interpeter" -> "interpReter" in first line.
Any reason not to check in the example and close the bug?
msg2332 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003年03月02日 13:27
Logged In: YES 
user_id=6380
Checked in.
History
Date User Action Args
2022年04月10日 16:03:28adminsetgithub: 33445
2000年11月03日 20:31:21anonymouscreate

AltStyle によって変換されたページ (->オリジナル) /