@@ -43,8 +43,8 @@ def __init__(self, bot):
43
43
self .logger = logging .getLogger (__name__ )
44
44
self .__lock = Lock ()
45
45
self .__tick = Event ()
46
- self .next_peek = None
47
- self .running = False
46
+ self ._next_peek = None
47
+ self ._running = False
48
48
49
49
def put (self , job , next_t = None , prevent_autostart = False ):
50
50
"""
@@ -70,11 +70,11 @@ def put(self, job, next_t=None, prevent_autostart=False):
70
70
self .queue .put ((next_t , job ))
71
71
72
72
# Wake up the loop if this job should be executed next
73
- if not self .next_peek or self .next_peek > next_t :
74
- self .next_peek = next_t
73
+ if not self ._next_peek or self ._next_peek > next_t :
74
+ self ._next_peek = next_t
75
75
self .__tick .set ()
76
76
77
- if not self .running and not prevent_autostart :
77
+ if not self ._running and not prevent_autostart :
78
78
self .logger .debug ('Auto-starting JobQueue' )
79
79
self .start ()
80
80
@@ -116,11 +116,11 @@ def tick(self):
116
116
continue
117
117
118
118
self .logger .debug ('Next task isn\' t due yet. Finished!' )
119
- self .next_peek = t
119
+ self ._next_peek = t
120
120
break
121
121
122
122
else :
123
- self .next_peek = None
123
+ self ._next_peek = None
124
124
125
125
self .__tick .clear ()
126
126
@@ -130,8 +130,8 @@ def start(self):
130
130
"""
131
131
self .__lock .acquire ()
132
132
133
- if not self .running :
134
- self .running = True
133
+ if not self ._running :
134
+ self ._running = True
135
135
self .__lock .release ()
136
136
job_queue_thread = Thread (target = self ._start , name = "job_queue" )
137
137
job_queue_thread .start ()
@@ -146,8 +146,8 @@ def _start(self):
146
146
queue.
147
147
"""
148
148
149
- while self .running :
150
- self .__tick .wait (self .next_peek and self .next_peek - time .time ())
149
+ while self ._running :
150
+ self .__tick .wait (self ._next_peek and self ._next_peek - time .time ())
151
151
152
152
# If we were woken up by set(), wait with the new timeout
153
153
if self .__tick .is_set ():
@@ -163,7 +163,7 @@ def stop(self):
163
163
Stops the thread
164
164
"""
165
165
with self .__lock :
166
- self .running = False
166
+ self ._running = False
167
167
168
168
self .__tick .set ()
169
169
0 commit comments