Last active
August 22, 2016 01:44
-
-
Save brodieG/8eaccf0e1bb7cb2f60f1ecfcd26b473c to your computer and use it in GitHub Desktop.
Illustrate Connection Issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f1 <- tempfile() | |
f2 <- tempfile() | |
cat("hello\n", file=f1) | |
cat("goodbye\n", file=f2) | |
con1 <- file(f1) | |
open(con1) | |
getAllConnections() | |
close(con1) | |
con2 <- file(f2) | |
open(con2) | |
# Doesn't work | |
con1 %in% getAllConnections() | |
## [1] TRUE | |
# This check may make it work, in addition to checking getAllConnections() | |
f1 %in% showConnections()[, 1] | |
## [1] FALSE | |
f2 %in% showConnections()[, 1] | |
## [1] TRUE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The particularly terrible thing in all this is that
con1
ends up pointing to the same place ascon2
... for exampleisOpen(con1)
returns TRUE. Internals shouldn't re-use connection ids.