Re: Too many file descriptors

2017-05-30 Thread Henrik Sarvell
That went too fast, it can't work the way I suggested, below works and is
tested:

(dm rssToPages> @
   (let (Str (or (next) (exclient~call (; This rssLink) "" 5)) Fd (pipe
(prin Str)))
  (for A (rss~parseFrom Fd)
 (let Url
(req!> '+Url
   'link (a; A 'htmlUrl)
   'title (a; A 'title)
   'site This
   'pubAt (dtp~utcToStamp (a; A 'pubDate)) )
(linkUrl> '+SiteTag Url This) ) )
  (close Fd)) )




On Tue, May 30, 2017 at 10:20 PM, Henrik Sarvell <hsarv...@gmail.com> wrote:

> Thanks Alex,
>
> I've changed the look to your #1 suggestion now:
>
> (dm rssToPages> @
>(let Str (or (next) (exclient~call (; This rssLink) "" 5))
>   (for A (rss~parseFrom
> (pipe
>(prin Str)
>(let Url
>   (req!> '+Url
>  'link (a; A 'htmlUrl)
>  'title (a; A 'title)
>  'site This
>  'pubAt (dtp~utcToStamp (a; A 'pubDate)) )
>   (linkUrl> '+SiteTag Url This) ) ) ) ) ) )
>
> Should work right?
>
>
>
>
> On Tue, May 30, 2017 at 10:23 AM, Alexander Burger <a...@software-lab.de>
> wrote:
>
>> Hi Henrik,
>>
>> > I'm running into too many file descriptors (again), or rather a file
>> > descriptor leak.
>> > ...
>> >   (for A (rss~parseFrom (pipe (prin Str)))
>>
>> (pipe (prin Str))) is probably the culprit.
>>
>> 'pipe' has two forms of invocation:
>> 1. (pipe exe . prg) executes 'prg', and cleans up everything (wait for
>> child and
>>close the open file).
>> 2. (pipe exe) returns a file descriptor, to be used subsequently. So you
>> need to
>>remember it, and close it when done.
>>
>> ♪♫ Alex
>>
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: Too many file descriptors

2017-05-30 Thread Henrik Sarvell
Thanks Alex,

I've changed the look to your #1 suggestion now:

(dm rssToPages> @
   (let Str (or (next) (exclient~call (; This rssLink) "" 5))
  (for A (rss~parseFrom
(pipe
   (prin Str)
   (let Url
  (req!> '+Url
 'link (a; A 'htmlUrl)
 'title (a; A 'title)
 'site This
 'pubAt (dtp~utcToStamp (a; A 'pubDate)) )
  (linkUrl> '+SiteTag Url This) ) ) ) ) ) )

Should work right?




On Tue, May 30, 2017 at 10:23 AM, Alexander Burger <a...@software-lab.de>
wrote:

> Hi Henrik,
>
> > I'm running into too many file descriptors (again), or rather a file
> > descriptor leak.
> > ...
> >   (for A (rss~parseFrom (pipe (prin Str)))
>
> (pipe (prin Str))) is probably the culprit.
>
> 'pipe' has two forms of invocation:
> 1. (pipe exe . prg) executes 'prg', and cleans up everything (wait for
> child and
>close the open file).
> 2. (pipe exe) returns a file descriptor, to be used subsequently. So you
> need to
>remember it, and close it when done.
>
> ♪♫ Alex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Too many file descriptors

2017-05-30 Thread Alexander Burger
Hi Henrik,

> I'm running into too many file descriptors (again), or rather a file
> descriptor leak.
> ...
>   (for A (rss~parseFrom (pipe (prin Str)))

(pipe (prin Str))) is probably the culprit.

'pipe' has two forms of invocation:
1. (pipe exe . prg) executes 'prg', and cleans up everything (wait for child and
   close the open file).
2. (pipe exe) returns a file descriptor, to be used subsequently. So you need to
   remember it, and close it when done.

♪♫ Alex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Too many file descriptors

2017-05-29 Thread Henrik Sarvell
Hi,

I know this has been discussed before but it looks like in IRC because I
can't find anything via Google.

I'm running into too many file descriptors (again), or rather a file
descriptor leak.

For completeness here is the whole flow:

1.) I loop a list of sites and access pre-downloaded RSS files like this:

(for S *Sites
   (let Str (in (pack *Downloads (; S id) ".xml") (till NIL T))
  (rssToPages> S Str)) )

2.) rssToPages> looks like this:

(dm rssToPages> @
   (let Str (or (next) (exclient~call (; This rssLink) "" 5))
  (for A (rss~parseFrom (pipe (prin Str)))
 (let Url
(req!> '+Url
   'link (a; A 'htmlUrl)
   'title (a; A 'title)
   'site This
   'pubAt (dtp~utcToStamp (a; A 'pubDate)) )
(linkUrl> '+SiteTag Url This) ) ) ) )

The exclient call will never happen in this case as we're passing in the
content in the argument.

rss~parseFrom is here:
https://bitbucket.org/hsarvell/ext/src/tip/rss.l?at=default=file-view-default

So as can be seen there's quite a lot of matching involved (in rss) which I
remember had something to do with open file descriptors, but also pipe and
in calls.

I don't know what is going wrong here because I feel like all open
descriptors should be closed on each conclusion of the site and/or article
loop. But they just seem to be accumulating for some reason.

/Henrik