Skip to content

Commit 406303d

Browse files
committed
refactor: running -> _running, next_peek -> _next_peek
1 parent 2534e0d commit 406303d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

telegram/ext/jobqueue.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def __init__(self, bot):
4343
self.logger = logging.getLogger(__name__)
4444
self.__lock = Lock()
4545
self.__tick = Event()
46-
self.next_peek = None
47-
self.running = False
46+
self._next_peek = None
47+
self._running = False
4848

4949
def put(self, job, next_t=None, prevent_autostart=False):
5050
"""
@@ -70,11 +70,11 @@ def put(self, job, next_t=None, prevent_autostart=False):
7070
self.queue.put((next_t, job))
7171

7272
# 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
7575
self.__tick.set()
7676

77-
if not self.running and not prevent_autostart:
77+
if not self._running and not prevent_autostart:
7878
self.logger.debug('Auto-starting JobQueue')
7979
self.start()
8080

@@ -116,11 +116,11 @@ def tick(self):
116116
continue
117117

118118
self.logger.debug('Next task isn\'t due yet. Finished!')
119-
self.next_peek = t
119+
self._next_peek = t
120120
break
121121

122122
else:
123-
self.next_peek = None
123+
self._next_peek = None
124124

125125
self.__tick.clear()
126126

@@ -130,8 +130,8 @@ def start(self):
130130
"""
131131
self.__lock.acquire()
132132

133-
if not self.running:
134-
self.running = True
133+
if not self._running:
134+
self._running = True
135135
self.__lock.release()
136136
job_queue_thread = Thread(target=self._start, name="job_queue")
137137
job_queue_thread.start()
@@ -146,8 +146,8 @@ def _start(self):
146146
queue.
147147
"""
148148

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())
151151

152152
# If we were woken up by set(), wait with the new timeout
153153
if self.__tick.is_set():
@@ -163,7 +163,7 @@ def stop(self):
163163
Stops the thread
164164
"""
165165
with self.__lock:
166-
self.running = False
166+
self._running = False
167167

168168
self.__tick.set()
169169

0 commit comments

Comments
 (0)