reportportal/client-Python

Meeting with race condition when trying to send logs to test case

rujutashinde opened this issue · 1 comments

Describe the bug
I am using reportportal-client with our code to import tests to our Reportportal instance. We are using python ThreadPoolExecutor where we start the import of testcases concurrently.
We call this method to send logs,

service.log(time=msg_time,
                         message=message,
                         level=level,
                         item_id=test_item_id)

where service = ReportPortalService(endpoint=endpoint, project=project, token=token)

2 calls to update the logs are coming in simultaneously where the list containing the logs to be posted is not cleaned up, and hence we are seeing multiple entries of the same log for a testcase.
This behavior is intermittent , this could be based on how quickly the api call finishes

The issue is happening when the method below is called :
https://github.com/reportportal/client-Python/blob/develop/reportportal_client/service.py#L531-L593

the list self._logs_batch list is cleared after the api call is made to the RP instance
https://github.com/reportportal/client-Python/blob/develop/reportportal_client/service.py#L584

If the list is cleared before the for loop which makes the api post , i do not see the race condition
https://github.com/reportportal/client-Python/blob/develop/reportportal_client/service.py#L579

Steps to Reproduce
see above

Expected behavior
when logs are posted each testcase should have its logs

Actual behavior
when logs are posted some testcases are seen with multiple entries of the same log

Package versions
reportportal-client==5.2.5

Additional context
Add any other context about the problem here.