@@ -51,8 +51,8 @@ def is_stop_cmd(self) -> bool:
5151 def priority (self ) -> Priority :
5252 """Get the priority of the command."""
5353 if self is ControlCommand .STOP_IMMEDIATE :
54- return Priority .PRIORITY_IMMEDIATE
55- return Priority .PRIORITY_LOW
54+ return Priority ( Priority .PRIORITY_IMMEDIATE )
55+ return Priority ( Priority .PRIORITY_LOW )
5656
5757 def __lt__ (self , other : Union ["ControlCommand" , "HttpRequest" ]) -> bool :
5858 """Priority protocol for the PriorityQueue."""
@@ -88,7 +88,7 @@ def _command_get(self) -> Optional[ControlCommand]:
8888 except queue .Empty :
8989 return None
9090
91- def _command_process (self , cmd : Optional [ ControlCommand ] ) -> None :
91+ def _command_process (self , cmd : ControlCommand ) -> None :
9292 """Process control command sent to the worker.
9393
9494 :param cmd: a command to be processed
@@ -157,7 +157,7 @@ def _stop_immediately(self) -> None:
157157 may be some records still left on the queue, which won't be processed.
158158 """
159159 self ._stop_lock .acquire ()
160- if self ._thread .is_alive () and self ._thread is not current_thread ():
160+ if self ._thread is not None and self . _thread .is_alive () and self ._thread is not current_thread ():
161161 self ._thread .join (timeout = THREAD_TIMEOUT )
162162 self ._thread = None
163163 self ._stop_lock .notify_all ()
@@ -168,7 +168,7 @@ def is_alive(self) -> bool:
168168
169169 :return: True is self._thread is not None, False otherwise
170170 """
171- return bool ( self ._thread ) and self ._thread .is_alive ()
171+ return self ._thread is not None and self ._thread .is_alive ()
172172
173173 def send (self , entity : Union [ControlCommand , HttpRequest ]) -> None :
174174 """Send control command or a request to the worker queue."""
0 commit comments