diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-12-23 00:30:03 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-12-23 00:30:03 (GMT) |
commit | 511a0720ea9f4278cd6c491bbb1e8c895e91e342 (patch) | |
tree | 22a482422e8b03e37e18ec6b3552714d7c15b834 /src/helsinki.at/rhimportd | |
parent | 280ddca779f66d601f515af815dcb6640d32cc7b (diff) |
session now has a timeout
Diffstat (limited to 'src/helsinki.at/rhimportd')
-rw-r--r-- | src/helsinki.at/rhimportd/main.go | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/helsinki.at/rhimportd/main.go b/src/helsinki.at/rhimportd/main.go index dee6b37..56fe612 100644 --- a/src/helsinki.at/rhimportd/main.go +++ b/src/helsinki.at/rhimportd/main.go @@ -93,36 +93,35 @@ func session_test(conf *rhimport.Config, rddb *rhimport.RdDbChan) { } var session *rhimport.SessionChan - if session, err = store.Get(ctx.UserName, "<test>"); err != nil { - rhl.Printf("MAIN: (Expected) Error SessionStore.Get(): %s", err) - } if session, err = store.Get(ctx.UserName, id); err != nil { rhl.Printf("MAIN: Error SessionStore.Get(): %s", err) return } - pch := make(chan string, 1000) - if err = session.AddProgressHandler((chan<- string)(pch), session_test_progress1); err != nil { - rhl.Printf("MAIN: Error Session.AddProgressHandler(): %s", err) - } - dch := make(chan rhimport.ImportResult) + dch := make(chan rhimport.ImportResult, 1) if err = session.AddDoneHandler((chan<- rhimport.ImportResult)(dch), session_test_done); err != nil { rhl.Printf("MAIN: Error Session.AddDoneHandler(): %s", err) + return } - rhl.Printf("MAIN: calling run for %s/%s", ctx.UserName, id) - session.Run() + // pch := make(chan string, 10) + // if err = session.AddProgressHandler((chan<- string)(pch), session_test_progress1); err != nil { + // rhl.Printf("MAIN: Error Session.AddProgressHandler(): %s", err) + // } + // go func() { + // time.Sleep(3 * time.Second) + // if err = session.AddProgressHandler((chan<- string)(pch), session_test_progress2); err != nil { + // rhl.Printf("MAIN: Error Session.AddProgressHandler(): %s", err) + // } + // }() - time.Sleep(500 * time.Millisecond) - - if err = session.AddProgressHandler((chan<- string)(pch), session_test_progress2); err != nil { - rhl.Printf("MAIN: Error Session.AddProgressHandler(): %s", err) - } + rhl.Printf("MAIN: calling run for %s/%s", ctx.UserName, id) + session.Run(10 * time.Second) for { select { - case p := <-pch: - fmt.Println(p) + // case p := <-pch: + // fmt.Println(p) case r := <-dch: fmt.Printf("Import finished: %+v\n", r) break |