Commit 4d24411 1 parent e036fcf commit 4d24411 Copy full SHA for 4d24411
File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -26,10 +26,12 @@ pub struct Scraper {
26
26
gh : Arc < Github > ,
27
27
data : Data ,
28
28
finished : Arc < AtomicBool > ,
29
+ timeout : Option < u64 > ,
29
30
}
30
31
31
32
impl Scraper {
32
33
pub fn new ( config : Config , data : Data ) -> Self {
34
+ let timeout = config. timeout ;
33
35
let gh = Github :: new ( config) ;
34
36
35
37
let finished = Arc :: new ( AtomicBool :: new ( false ) ) ;
@@ -45,6 +47,7 @@ impl Scraper {
45
47
gh : Arc :: new ( gh) ,
46
48
data,
47
49
finished,
50
+ timeout
48
51
}
49
52
}
50
53
@@ -97,7 +100,12 @@ impl Scraper {
97
100
98
101
loop {
99
102
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
+ }
101
109
102
110
let mut repos = self . gh . scrape_repositories ( last_id) . await ?;
103
111
let mut js = JoinSet :: new ( ) ;
You can’t perform that action at this time.
0 commit comments