mrkn / pycall.rb

Calling Python functions from the Ruby language
MIT License
1.05k stars 72 forks source link

call with docx module, GIL is released (the current Python thread state is NULL) #171

Open sforce100 opened 11 months ago

sforce100 commented 11 months ago

my python script call second time, get this error :

Fatal Python error: PyThreadState_Get: the function must be called with the GIL held, but the GIL is released (the current Python thread state is NULL) Python runtime state: initialized

my python script is:

from docx import Document

from docx.text.paragraph import Paragraph
from docx.table import Table
from docx.oxml.text.paragraph import CT_P
from docx.oxml.table import CT_Tbl

def trans_text(text):
    from harvesttext import HarvestText
    ht0 = HarvestText()
    return ht0.clean_text(text)

def extract_all_table_data_with_context(docx_filename):

    doc = Document(docx_filename)
    all_table_data = []
    table_context = None
    current_table_data = None
    for child in doc.element.body.iterchildren():
        print(child)
mrkn commented 3 months ago

@sforce100 How do I reproduce the error?