File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -76,12 +76,13 @@ def stopped(self):
76
76
@lockandrun
77
77
def update (self , item ):
78
78
"""Simulate an plugin update method."""
79
- s = random .uniform (0 , 10 )
80
79
logging .info ('Update processe started' )
81
- self . _stats . append ( item )
82
- t = Timer (s )
80
+ # Simulate an update
81
+ t = Timer (random . uniform ( 0 , 5 ) )
83
82
while not t .finished () and not self .stopped ():
84
83
sleep (0.01 )
84
+ self ._stats .append (item )
85
+ # /Simulate an update
85
86
if self .stopped ():
86
87
logging .info ('Update processes stopped' )
87
88
else :
Original file line number Diff line number Diff line change 5
5
# Nicolargo (08/2017)
6
6
7
7
import signal
8
- import sys
9
8
import threading
10
9
from plugin import Plugin
11
10
@@ -28,16 +27,19 @@ def __init__(self):
28
27
self .plugins_list .append (Plugin (name = 'plugin%s' % (i - 1 )))
29
28
30
29
def update (self ):
30
+ # Init the threads list
31
31
self .plugin_threads = []
32
32
for i in range (0 , 9 ):
33
33
t = threading .Thread (name = 'plugin%s' % i ,
34
34
target = self .plugins_list [i ].update ,
35
35
args = (i ,))
36
36
self .plugin_threads .append (t )
37
+ # Start all the threads
37
38
t .start ()
39
+ # Wait all the threads
40
+ t .join ()
38
41
39
42
def stop (self , signal , frame ):
40
- print ('CTRL-C pressed' )
41
43
for i in range (0 , 9 ):
42
44
self .plugins_list [i ].stop ()
43
45
You can’t perform that action at this time.
0 commit comments