Limit download speed to not kill internet

This commit is contained in:
2024-06-21 22:23:02 +02:00
parent be38b3d602
commit 089e7f637f
2 changed files with 12 additions and 4 deletions

View File

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