Fix issue with fake deadlock
This commit is contained in:
28
main.go
28
main.go
@@ -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)
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user