Fix issue with fake deadlock

This commit is contained in:
2024-06-17 21:11:19 +02:00
parent 6f2b472c83
commit eb43976857

28
main.go
View File

@@ -46,17 +46,21 @@ func main() {
listener.initialize() listener.initialize()
status := make(chan error) status := make(chan error)
for event := range listener.Create { for {
log.Printf("Create event: %+v\n", event) select {
eventCopy := event case event := <-listener.Create:
go func() { log.Printf("Create event: %+v\n", event)
Download(eventCopy, status) eventCopy := event
// go DownloadNative(event, status) go func() {
for status := range status { Download(eventCopy, status)
log.Printf("Status: %s\n", status) // go DownloadNative(event, status)
} for status := range status {
}() log.Printf("Status: %s\n", status)
}
}()
case <-time.After(1 * time.Minute):
// Perform some action or simply continue to avoid deadlock
log.Println("Consumer is alive, but has no new events.")
}
} }
time.Sleep(1 * time.Hour)
} }