Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

threads within an embedded python interpreter #33445

Closed
anonymous mannequin opened this issue Nov 3, 2000 · 8 comments
Closed

threads within an embedded python interpreter #33445

anonymous mannequin opened this issue Nov 3, 2000 · 8 comments
Assignees
Labels
docs Documentation in the Doc dir

Comments

@anonymous
Copy link
Mannequin

anonymous mannequin commented Nov 3, 2000

BPO 221327
Nosy @gvanrossum, @loewis, @akuchling
Files
  • init.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/loewis'
    closed_at = <Date 2003-03-02.13:27:07.000>
    created_at = <Date 2000-11-03.20:31:21.000>
    labels = ['docs']
    title = 'threads within an embedded python interpreter'
    updated_at = <Date 2003-03-02.13:27:07.000>
    user = 'https://bugs.python.org/anonymous'

    bugs.python.org fields:

    activity = <Date 2003-03-02.13:27:07.000>
    actor = 'gvanrossum'
    assignee = 'loewis'
    closed = True
    closed_date = None
    closer = None
    components = ['Documentation']
    creation = <Date 2000-11-03.20:31:21.000>
    creator = 'anonymous'
    dependencies = []
    files = ['7']
    hgrepos = []
    issue_num = 221327
    keywords = []
    message_count = 8.0
    messages = ['2325', '2326', '2327', '2328', '2329', '2330', '2331', '2332']
    nosy_count = 5.0
    nosy_names = ['gvanrossum', 'nobody', 'loewis', 'jhylton', 'akuchling']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue221327'
    versions = []

    @nobody
    Copy link
    Mannequin

    nobody mannequin commented Nov 3, 2000

    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

    @anonymous anonymous mannequin closed this as completed Nov 3, 2000
    @anonymous anonymous mannequin closed this as completed Nov 3, 2000
    @anonymous anonymous mannequin assigned loewis Nov 3, 2000
    @anonymous anonymous mannequin added docs Documentation in the Doc dir labels Nov 3, 2000
    @gvanrossum
    Copy link
    Member

    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.

    @nobody
    Copy link
    Mannequin

    nobody mannequin commented Aug 31, 2001

    Logged In: NO

    Now u pay,.

    @jhylton
    Copy link
    Mannequin

    jhylton mannequin commented Mar 1, 2002

    Logged In: YES
    user_id=31392

    Probably ought to fix this for 2.3

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    but is it a doco bug or not?

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Aug 4, 2002

    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.

    @akuchling
    Copy link
    Member

    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?

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    Checked in.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants