Pre Merge pull request !32 from Marquez/N/A

This commit is contained in:
Marquez 2024-01-14 23:27:46 +00:00 committed by Gitee
commit 25515c8e4f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -113,13 +113,13 @@ class Listener(object):
self._set_callback()
self.listening = True
def wait(self, count=1, timeout=None, fit_count=True, raise_err=None):
def wait(self, count=1, timeout=None, fix_count=True, raise_err=None):
"""等待符合要求的数据包到达指定数量
:param count: 需要捕捉的数据包数量
:param timeout: 超时时间为None无限等待
:param fit_count: 是否必须满足总数要求发生超时为True返回False为False返回已捕捉到的数据包
:param fix_count: 是否必须满足总数要求发生超时为True返回False为False返回已捕捉到的数据包
:param raise_err: 超时时是否抛出错误为None时根据Settings设置
:return: count为1时返回数据包对象大于1时返回列表超时且fit_count为True时返回False
:return: count为1时返回数据包对象大于1时返回列表超时且fix_count为True时返回False
"""
if not self.listening:
raise RuntimeError('监听未启动或已暂停。')
@ -139,7 +139,7 @@ class Listener(object):
break
if fail:
if fit_count or not self._caught.qsize():
if fix_count or not self._caught.qsize():
if raise_err is True or Settings.raise_when_wait_failed is True:
raise WaitTimeoutError(f'等待数据包失败(等待{timeout}秒)。')
else: