Skip to content

Commit 6252a53

Browse files
committed
Check for parent RPClient object in thread before logging
1 parent 130d023 commit 6252a53

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

33
## [Unreleased]
4+
### Added
5+
- Check for parent `RPClient` object in thread before logging, by @HardNorth
46

57
## [5.3.3]
68
### Added

reportportal_client/logs/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414

1515
import logging
1616
import sys
17+
import threading
1718

1819
from six import PY2
1920
from six.moves.urllib.parse import urlparse
2021

2122
# noinspection PyProtectedMember
22-
from reportportal_client._local import current
23+
from reportportal_client._local import current, set_current
2324
from reportportal_client.helpers import timestamp
2425

2526

@@ -177,6 +178,11 @@ def emit(self, record):
177178
rp_client = self.rp_client
178179
if not rp_client:
179180
rp_client = current()
181+
if not rp_client:
182+
rp_client = getattr(threading.current_thread(),
183+
'parent_rp_client', None)
184+
if rp_client:
185+
set_current(rp_client)
180186
if rp_client:
181187
rp_client.log(
182188
timestamp(),

0 commit comments

Comments
 (0)