File tree 1 file changed +12
-11
lines changed
1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -17,17 +17,18 @@ def run(self) -> None:
17
17
while not self ._exit_event .is_set ():
18
18
successful_read = False
19
19
for fileno , watched_file in self ._file_descriptors .items ():
20
- try :
21
- position = lseek (fileno , 0 , SEEK_CUR )
22
- if chunk := read (fileno , chunk_size ):
23
- successful_read = True
24
- breaks = scan_chunk (chunk , position )
25
- watched_file .callback (position + len (chunk ), breaks )
26
- position += len (chunk )
27
- except Exception as error :
28
- watched_file .error_callback (error )
29
- self ._file_descriptors .pop (fileno , None )
30
- break
20
+ with watched_file ._lock :
21
+ try :
22
+ position = lseek (fileno , 0 , SEEK_CUR )
23
+ if chunk := read (fileno , chunk_size ):
24
+ successful_read = True
25
+ breaks = scan_chunk (chunk , position )
26
+ watched_file .callback (position + len (chunk ), breaks )
27
+ position += len (chunk )
28
+ except Exception as error :
29
+ watched_file .error_callback (error )
30
+ self ._file_descriptors .pop (fileno , None )
31
+ break
31
32
else :
32
33
if not successful_read :
33
34
time .sleep (0.05 )
You can’t perform that action at this time.
0 commit comments