It's not about what Go can handle, but what resources you are providing
to the process. Each request could take more than one file descriptor, one
for the dns query and one for the tcp connection. I don't think it's your
problem here, but something to watch.
TY -- yes, I've been watching file descriptors.

You don't need to check for `resp == nil`. If the error nil, resp will
be usable, and resp.Body is guaranteed to be non-nil.
What if the remote server returns an empty response?

What is an empty response? If it's a valid http response with no body, the
response.Body will return 0 bytes. If the server closed the connection or
sent something invalid, then you get an error.
Makes sense. I should just handle the case if resp.Body == 0 bytes.

In your actual code, is it possible that you have clients stuck sending
to articleChan? That would leave their respective response bodies open,
since it doesn't hit the defer.
It could -- if main execution continues as the loop timeout is hit.
Wouldn't it hit defer when the goroutine returns, even if main execution
has moved on?
In this example code, the download goroutine can't return if nothing is
receiving from articleChan. That send needs a synchronous receive on the
other side. If you are leaking goroutines like this in the real code, you
either need to buffer articleChan or receive from articleChan until all the
download goroutines have returned.
I am leaking goroutines. I've been assuming that they get GC'd eventually,
but it's sloppy code.

Buffering sounds like a good solution. Can you point me in the right
direction of what to read up on?

You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 10 of 15 | next ›
Discussion Overview
groupgolang-nuts @
postedJan 19, '15 at 4:38p
activeJan 21, '15 at 3:59p



site design / logo © 2022 Grokbase