File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -26,10 +26,12 @@ pub struct Scraper {
2626 gh : Arc < Github > ,
2727 data : Data ,
2828 finished : Arc < AtomicBool > ,
29+ timeout : Option < u64 > ,
2930}
3031
3132impl Scraper {
3233 pub fn new ( config : Config , data : Data ) -> Self {
34+ let timeout = config. timeout ;
3335 let gh = Github :: new ( config) ;
3436
3537 let finished = Arc :: new ( AtomicBool :: new ( false ) ) ;
@@ -45,6 +47,7 @@ impl Scraper {
4547 gh : Arc :: new ( gh) ,
4648 data,
4749 finished,
50+ timeout,
4851 }
4952 }
5053
@@ -97,7 +100,12 @@ impl Scraper {
97100
98101 loop {
99102 let start_loop = Instant :: now ( ) ;
100- // TODO check timeout
103+ if let Some ( timeout) = self . timeout {
104+ if start. elapsed ( ) >= Duration :: from_secs ( timeout) {
105+ info ! ( "Timeout reached, stopped scraping" ) ;
106+ break ;
107+ }
108+ }
101109
102110 let mut repos = self . gh . scrape_repositories ( last_id) . await ?;
103111 let mut js = JoinSet :: new ( ) ;
You can’t perform that action at this time.
0 commit comments