[plt-scheme] ports and garbage collection
I've been using code like this to make a bunch of XML queries via HTTP POST:
(read-xml (post-pure-port url query))
Now suddenly I get a "host not found" error, and then "Too many open
files" when I try to open a file to save data. I thought ports
were closed when garbage collected, but apparently not. How come?
It seems tedious to have to close ports manually:
(let ((in (post-pure-port url query)))
(begin0 (read-xml in)
(close-input-port in)))
but maybe I'm just spoiled.
--dougo at place.org