Skip to content

Commit

Permalink
Remove redundant lock
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Jun 23, 2022
1 parent 2ff8214 commit 2d7980b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 3 additions & 4 deletions reportportal_client/core/log_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ def __init__(self, rp_url, session, api_version, launch_id, project_name,
:param max_payload_size: maximum size in bytes of logs that can be
processed in one batch
"""
self._stop_lock = Lock()
self._size_lock = Lock()
self._lock = Lock()
self._batch = []
self._payload_size = helpers.TYPICAL_MULTIPART_FOOTER_LENGTH
self._worker = None
Expand Down Expand Up @@ -89,7 +88,7 @@ def _log_process(self, log_req):
:param log_req: RPRequestLog object
"""
with self._size_lock:
with self._lock:
rq_size = log_req.multipart_size
if self._payload_size + rq_size >= self.max_payload_size:
if len(self._batch) > 0:
Expand Down Expand Up @@ -127,7 +126,7 @@ def start(self):
def stop(self):
"""Send last batches to the worker followed by the stop command."""
if self._worker:
with self._stop_lock:
with self._lock:
if self._batch:
self._send_batch()
logger.debug('Waiting for worker {0} to complete'
Expand Down
3 changes: 1 addition & 2 deletions reportportal_client/core/log_manager.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ MAX_LOG_BATCH_PAYLOAD_SIZE: int


class LogManager:
_stop_lock: Lock = ...
_size_lock: Lock = ...
_lock: Lock = ...
_log_endpoint: Text = ...
_batch: List = ...
_payload_size: int = ...
Expand Down

0 comments on commit 2d7980b

Please sign in to comment.