[ 
https://issues.apache.org/jira/browse/ARROW-6531?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16927744#comment-16927744
 ] 

Antoine Pitrou commented on ARROW-6531:
---------------------------------------

Well, that's expected in Python:
{code:python}
>>> import io                                                                   
>>>                                                                             
>>>         
>>> raw = io.BytesIO()                                                          
>>>                                                                             
>>>         
>>> buffered = io.BufferedReader(raw)                                           
>>>                                                                             
>>>         
>>> raw.closed                                                                  
>>>                                                                             
>>>         
False
>>> del buffered                                                                
>>>                                                                             
>>>         
>>> raw.closed                                                                  
>>>                                                                             
>>>         
True
{code}

And you can use detach() to avoid it:
{code:python}
>>> raw = io.BytesIO()                                                          
>>>                                                                             
>>>         
>>> buffered = io.BufferedReader(raw)                                           
>>>                                                                             
>>>         
>>> buffered.detach()                                                           
>>>                                                                             
>>>         
<_io.BytesIO at 0x7f2280236938>
>>> del buffered                                                                
>>>                                                                             
>>>         
>>> raw.closed                                                                  
>>>                                                                             
>>>         
False
{code}


> [C++] Do not always close raw OutputStream in BufferedOutputStream::Close
> -------------------------------------------------------------------------
>
>                 Key: ARROW-6531
>                 URL: https://issues.apache.org/jira/browse/ARROW-6531
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: C++
>            Reporter: Wes McKinney
>            Priority: Major
>             Fix For: 0.15.0
>
>
> {{BufferedOutputStream::Close}} closes the raw file handle unconditionally. 
> This may be undesirable in some circumstances.
> Some alternatives:
> * Do not close it
> * Only close it if the {{use_count}} of the {{shared_ptr}} is 1, so we know 
> that no one else has a copy of the shared_ptr



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to