FAQ

On Tue, Jan 20, 2015 at 12:58 PM, Aki Balogh wrote:

Good point -- but I imagine go should be able to handle downloading a few
hundred websites concurrently, right? Most of the time is spent waiting on
the remote servers anyway.
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.


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.



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.

--
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

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 9 of 15 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 19, '15 at 4:38p
activeJan 21, '15 at 3:59p
posts15
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase