mirror of
https://github.com/KenanZhu/AutoLibrary.git
synced 2026-06-18 15:33:03 +08:00
optimize(MsgBase): 优化消息队列能力基类,增加小数秒精度时间戳,移除无用方法 '_inputMsg'
This commit is contained in:
+2
-14
@@ -7,8 +7,8 @@ This software is provided "as is", without any warranty of any kind.
|
|||||||
You may use, modify, and distribute this file under the terms of the MIT License.
|
You may use, modify, and distribute this file under the terms of the MIT License.
|
||||||
See the LICENSE file for details.
|
See the LICENSE file for details.
|
||||||
"""
|
"""
|
||||||
import time
|
|
||||||
import queue
|
import queue
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
class MsgBase:
|
class MsgBase:
|
||||||
@@ -53,7 +53,7 @@ class MsgBase:
|
|||||||
msg: str
|
msg: str
|
||||||
):
|
):
|
||||||
|
|
||||||
timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
|
||||||
self._output_queue.put(f"{timestamp}-[{self._class_name:<15}] : {msg}")
|
self._output_queue.put(f"{timestamp}-[{self._class_name:<15}] : {msg}")
|
||||||
|
|
||||||
|
|
||||||
@@ -67,15 +67,3 @@ class MsgBase:
|
|||||||
return msg
|
return msg
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _inputMsg(
|
|
||||||
self,
|
|
||||||
timeout: float = 1.0
|
|
||||||
) -> bool:
|
|
||||||
|
|
||||||
try:
|
|
||||||
self._input_queue.get(timeout=timeout)
|
|
||||||
return True
|
|
||||||
except queue.Empty:
|
|
||||||
return False
|
|
||||||
|
|||||||
Reference in New Issue
Block a user