The other suggestions are good practice. If you are on linux the following
commands will help you figure out which file or files you have open, and
therefore where in your code to look:
pidof julia
lsof -p XXXX # XXXX is from previous command
On Thursday, March 12, 2015 at 6:46:10 AM UTC-6, René Donner wrote:
>
>
> With that I was able to debug the problem in a snap. It turns out that one
>> of my functions had "readlines(open(...))" instead of
>> "open(readlines,...)". The critical difference is that the former leaves a
>> file pointer dangling.
>>
>
> Ah, ok, that's exactly the difference: using open(myfunc, filename) is the
> same as
>
> open(filename) do io
> myfunc(io)
> end
>
> Like this you never have to worry about closing files, even on exceptions.
>
> When using open without a function it looks like this:
>
> io = open(filename)
> myfunc(io)
> # this is crucial:
> close(io)
>
> In this version, when an exception occurs in myfunc the file will never be
> closed.
>
> Last note: the "do" syntax is not special for open but can be used with
> your own functions as well:
>
> function functhatneedsfunc(f, a)
> println("let's just apply f")
> f(a)
> end
>
> # lets call it:
> functhatneedsfunc(a) do x
> show(x)
> println("printed x!")
> end
>
>
>
>