Probleme mit Deadlocks durch Timeout im Ctx verhindern.
This commit is contained in:
parent
b3367d8e5e
commit
6f75f05e06
|
|
@ -48,10 +48,6 @@ func NewElioDateiFoo(lookUpDir string, process ElioHandleFunc) *ElioDateiFoo {
|
|||
// Veraltete Dateien mit Präfix no-import und Postifx .old benennen.
|
||||
// Gültige Dateinamen zur Extraktion in Closure übergeben.
|
||||
func (f *ElioDateiFoo) ScanCsv(ctx context.Context, data chan<- CountryCsvData) {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
fmt.Println("Abbruch angefordert im Verarbeitungsprozess.")
|
||||
default:
|
||||
files, err := os.ReadDir(f.lookUpDir)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
|
@ -93,10 +89,11 @@ func (f *ElioDateiFoo) ScanCsv(ctx context.Context, data chan<- CountryCsvData)
|
|||
f.mu.Lock()
|
||||
f.haveDone[v.filename] = time.Now()
|
||||
f.mu.Unlock()
|
||||
go func() {
|
||||
//Max 5 Sekunden zum Abarbeiten eines Datensatzes
|
||||
tctx, cancel := context.WithTimeout(ctx, time.Second*5)
|
||||
f.process(tctx, v.filename, data)
|
||||
cancel()
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue