Better cleanup of example session during check

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Better cleanup of example session during check

Thomas Lin Pedersen
I have a couple of packages (‘fiery’ and ‘reqres') that uses a mock of a rook request for their examples. The mock is an R6 object containing a rawConnection, along with a finalizer that closes this connection when the object is removed. So far so good. I’ve recently been getting CRAN errors due to the rawConnection not being closed in examples

> cleanEx()
Error: connections left open:
        content (rawConnection)

and the only way to remove this is by removing the objects and calling gc() as part of the example code. While it is possible to hide all that inside a \dontshow{} block, it appears to me that it would be better if cleanEx() did a cleaning of the environment along with a single gc call prior to performing any checks on the end state. Is this something you would consider?

best
Thomas Lin Pedersen
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Better cleanup of example session during check

Duncan Murdoch-2
On 12/11/2018 8:09 AM, Thomas Lin Pedersen wrote:
> I have a couple of packages (‘fiery’ and ‘reqres') that uses a mock of a rook request for their examples. The mock is an R6 object containing a rawConnection, along with a finalizer that closes this connection when the object is removed. So far so good. I’ve recently been getting CRAN errors due to the rawConnection not being closed in examples
>
>> cleanEx()
> Error: connections left open:
> content (rawConnection)
>
> and the only way to remove this is by removing the objects and calling gc() as part of the example code. While it is possible to hide all that inside a \dontshow{} block, it appears to me that it would be better if cleanEx() did a cleaning of the environment along with a single gc call prior to performing any checks on the end state. Is this something you would consider?

Wouldn't it be possible for you to add a way to explicitly request the
connection be closed?  Then the finalizer would only need to close it if
you forgot.


> best
> Thomas Lin Pedersen
> [[alternative HTML version deleted]]

This message was fine, but sometimes posting in HTML makes your message
unreadable.  This list wants plain text.

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Better cleanup of example session during check

Duncan Murdoch-2
On 12/11/2018 8:32 AM, Duncan Murdoch wrote:

> On 12/11/2018 8:09 AM, Thomas Lin Pedersen wrote:
>> I have a couple of packages (‘fiery’ and ‘reqres') that uses a mock of a rook request for their examples. The mock is an R6 object containing a rawConnection, along with a finalizer that closes this connection when the object is removed. So far so good. I’ve recently been getting CRAN errors due to the rawConnection not being closed in examples
>>
>>> cleanEx()
>> Error: connections left open:
>> content (rawConnection)
>>
>> and the only way to remove this is by removing the objects and calling gc() as part of the example code. While it is possible to hide all that inside a \dontshow{} block, it appears to me that it would be better if cleanEx() did a cleaning of the environment along with a single gc call prior to performing any checks on the end state. Is this something you would consider?
>
> Wouldn't it be possible for you to add a way to explicitly request the
> connection be closed?  Then the finalizer would only need to close it if
> you forgot.
>

After some private messages, it appears that having the example code
explicitly remove the object is enough to satisfy the check.  Presumably
this is because a garbage collection is happening before the error is
issued, and it triggers the finalizer.

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel