similar to: Checking on closed file connections

Displaying 20 results from an estimated 20000 matches similar to: "Checking on closed file connections"

2009 May 21
3
file descriptor leak in getSrcLines in R 2.10.0 svn 48590
I noticed the following file descriptor leak when I couldn't remove a package unless I shut down the R session that had loaded and used it. The function that triggered the problem printed the output of a call to parse(). Each time one prints a srcref a connection is opened and not closed. It looks like it happens in as.character.srcref's call to getSrcLines, which has some logic I
2000 Dec 20
1
unlink() is not synchronized with existing connections (PR#783)
> # creating a file > cat("sddfasdf", file="tempfile") > showConnections() class description mode text isopen can read can write > con <- file("tempfile", "r") > readLines(con) [1] "sddfasdf" Warning message: incomplete final line in: readLines(con, n, ok) > showConnections() class description mode text isopen
2007 Nov 14
1
isOpen on closed connections
As far as I can tell, 'isOpen' cannot return FALSE in the case when 'rw = ""'. If the connection has already been closed by 'close' or some other function, then isOpen will produce an error. The problem is that when isOpen calls 'getConnection', the connection cannot be found and 'getConnection' produces an error. The check to see if it is
2001 Oct 02
1
connections: remember to close it!
Hi all, I have newly discovered the power of connections (although just a small part of it, namely the file() connection). It allowed me to process data file with arbitrary number of fields per line, which I was using awk for preprocessing before readling into R. The combination of the connection, readLines() and strsplit() really make the work a lot easier and more organized. Thanks a bundle
2017 Dec 14
4
cannot destroy connection (?) created by readLines in a tryCatch
On Thu, Dec 14, 2017 at 7:56 PM, Gabriel Becker <gmbecker at ucdavis.edu> wrote: > Gabor, > > You can grab the connection and destroy it via getConnection and then a > standard close call. Yeah, that's often a possible workaround, but since this connection was opened by readLines() internally, I don't necessarily know which one it is. E.g. I might open multiple
2000 Dec 20
0
showConnections() does not show closed (or non-opened) connections though help says so (PR#784)
help on showConnections explains parameter all logical: if true all connections, including closed ones and the standard ones are displayed. If false only open user-created connections are included. but > # create a file > cat("TITLE extra line", "2 3 5 7", "", "11 13 17", file="ex.data", + sep="\n") >
2000 Dec 20
1
showConnections() does not show closed (or non-opened) connections though help says so
help on showConnections explains parameter all logical: if true all connections, including closed ones and the standard ones are displayed. If false only open user-created connections are included. but > # create a file > cat("TITLE extra line", "2 3 5 7", "", "11 13 17", file="ex.data", + sep="\n") >
2006 Mar 25
2
R gets slow
Hello, I have R as a socket server that computes R code sent by some scripts (the clients). These scrips send R code to generate models (SVM). The problem is that first models are generated in less than one second and one hour later, the same models are generated in more than ten seconds (even training with same data). If I restart the server , then it works well (fast). I don't know if I have
2017 Dec 14
2
cannot destroy connection (?) created by readLines in a tryCatch
Consider this code. This is R 3.4.2, but based on a quick look at the NEWS, this has not been fixed. tryCatch( readLines(tempfile(), warn = FALSE)[1], error = function(e) NA, warning = function(w) NA ) rm(list=ls(all.names = TRUE)) gc() showConnections(all = TRUE) If you run it, you'll get a connection you cannot close(), i.e. the last showConnections() call prints: ?
2005 Apr 14
2
documentation for 'open': some clarification?
I'm been doing more and more of file text parsing inside R instead of coping with Perl. For that, I need open a file and read it line-by-line. I found the documentation for 'open' isn't very clear. Right now it has ,----[ *help(R)[open]* ] | 'open' opens a connection. In general functions using connections | will open them if they are not open, but then close them
2017 Dec 15
1
cannot destroy connection (?) created by readLines in a tryCatch
Thanks for tracking this down. Yeah, I should use suppressWarnings(), you are right. Although, readLines() might throw another warning, e.g. for incomplete last lines, and you don't necessarily want to suppress that. TBH I am not sure why that warning is given: ? con <- file(tempfile()) ? open(con) Error in open.connection(con) : cannot open the connection In addition: Warning message: In
2016 Nov 13
1
Memory leak with tons of closed connections
Using dup() before fdopen() (and calling fclose() on the connection when it is closed) indeed fixes the memory leak. FYI, Gabor Index: src/main/connections.c =================================================================== --- src/main/connections.c (revision 71653) +++ src/main/connections.c (working copy) @@ -576,7 +576,7 @@ fp = R_fopen(name, con->mode); } else { /* use
2011 Apr 08
1
Invalid connection after closing?
Dear all, I do not completely understand following behaviour : > con <- file("test.txt") > isOpen(con) [1] FALSE > open(con) > isOpen(con) [1] TRUE > close(con) > isOpen(con) Error in isOpen(con) : invalid connection > str(con) Classes 'file', 'connection' atomic [1:1] 3 ..- attr(*, "conn_id")=<externalptr> Why do I get an
2012 Feb 12
3
Writing output into a file
Hi everyone, I'm an R newbie working with the poLCA module. I achieved my target without having to bother anyone, but It seems that I've got stuck at the last minute. My problem is simple. I need to write my results into a file. My results are in the shape of a list (unbalanced columns) I've considered several methods (sink(), write.file) etc. etc. Unfortunately, I'm not the best
2000 Dec 20
0
unlink() is not synchronized with existing connections (PR#785)
On Wed, 20 Dec 2000 joehl@web.de wrote: > > # creating a file > > cat("sddfasdf", file="tempfile") > > showConnections() > class description mode text isopen can read can write > > con <- file("tempfile", "r") > > readLines(con) > [1] "sddfasdf" > Warning message: > incomplete final line in:
2014 Jun 19
1
isOpen() misbehaviour
Hello, >From the doc, it says: "isOpen returns a logical value, whether the connection is currently open." But actually it seems to die on closed connections: > con <- file() > isOpen(con) [1] TRUE > close(con) > isOpen(con) Error in isOpen(con) : invalid connection Is it expected ? Tested on R-3.0.2 and R version 3.1.0 Patched (2014-06-11 r65921) on linux x86_64
2000 Dec 20
1
unlink() is not synchronized with existing connections
> # creating a file > cat("sddfasdf", file="tempfile") > showConnections() class description mode text isopen can read can write > con <- file("tempfile", "r") > readLines(con) [1] "sddfasdf" Warning message: incomplete final line in: readLines(con, n, ok) > showConnections() class description mode text isopen
2017 Dec 14
0
cannot destroy connection (?) created by readLines in a tryCatch
On Thu, Dec 14, 2017 at 12:17 PM, G?bor Cs?rdi <csardi.gabor at gmail.com> wrote: > On Thu, Dec 14, 2017 at 7:56 PM, Gabriel Becker <gmbecker at ucdavis.edu> > wrote: > > Gabor, > > > > You can grab the connection and destroy it via getConnection and then a > > standard close call. > > Yeah, that's often a possible workaround, but since this
2003 Mar 01
1
RE: [R] File opening error after 1020 files opened
Maybe open.connection() should also check if the connection is already open and given an error or at least a warning if it is. Suggested code update: open.connection <- function(con, open="r", blocking=TRUE, ...) { if (!inherits(con, "connection")) stop("argument is not a connection") if (isOpen(con)) # NEW
2003 Aug 27
2
Using files as connections
I have been trying to read a random sample of lines from a file into a data frame using readLines(). The help indicates that readLines() will start from the current line if the connection is open, but presented with a closed connection it will open it, start from the beginning, and close it when finished. In the code that follows I tried to open the file before reading but apparently without