pitrou commented on issue #38676:
URL: https://github.com/apache/arrow/issues/38676#issuecomment-1808779206

   A fix for this precise issue would be this patch:
   ```diff
   diff --git a/python/pyarrow/_csv.pyx b/python/pyarrow/_csv.pyx
   index e532d8d8ab..bea9c5789e 100644
   --- a/python/pyarrow/_csv.pyx
   +++ b/python/pyarrow/_csv.pyx
   @@ -1252,7 +1252,7 @@ def read_csv(input_file, read_options=None, 
parse_options=None,
            CCSVConvertOptions c_convert_options
            CIOContext io_context
            shared_ptr[CCSVReader] reader
   -        shared_ptr[CTable] table
   +        CResult[shared_ptr[CTable]] table_result
    
        _get_reader(input_file, read_options, &stream)
        _get_read_options(read_options, &c_read_options)
   @@ -1263,14 +1263,16 @@ def read_csv(input_file, read_options=None, 
parse_options=None,
            io_context = CIOContext(
                maybe_unbox_memory_pool(memory_pool),
                (<StopToken> stop_handler.stop_token).stop_token)
   -        reader = GetResultValue(CCSVReader.Make(
   -            io_context, stream,
   -            c_read_options, c_parse_options, c_convert_options))
    
            with nogil:
   -            table = GetResultValue(reader.get().Read())
   -
   -    return pyarrow_wrap_table(table)
   +            reader = GetResultValue(CCSVReader.Make(
   +                io_context, stream,
   +                c_read_options, c_parse_options, c_convert_options))
   +            table_result = reader.get().Read()
   +            # Make sure the C++ destructor runs without the GIL (GH-38676)
   +            reader.reset()
   +
   +        return pyarrow_wrap_table(GetResultValue(table_result))
    
    
    def open_csv(input_file, read_options=None, parse_options=None,
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to