Limit download speed to not kill internet
This commit is contained in:
@@ -43,13 +43,20 @@ func main() {
|
||||
ws.url = WEBSOCKET_SERVER
|
||||
ws.Open()
|
||||
|
||||
status := make(chan error, 16)
|
||||
sem := make(chan struct{}, 4)
|
||||
for {
|
||||
select {
|
||||
case event := <-ws.ReadChan:
|
||||
eventCopy := event
|
||||
log.Printf("New event: %+v", eventCopy)
|
||||
status := make(chan error)
|
||||
sem <- struct{}{}
|
||||
|
||||
log.Printf("New event: %+v; semaphore at: %d", eventCopy, len(sem))
|
||||
go func() {
|
||||
defer func() {
|
||||
<-sem
|
||||
log.Printf("Semaphore at: %d", len(sem))
|
||||
}()
|
||||
// Download(eventCopy, status)
|
||||
DownloadURL(eventCopy, status)
|
||||
// go DownloadNative(event, status)
|
||||
|
Reference in New Issue
Block a user