Skip to content

Commit

Permalink
test/rgw/notification: avoid BlockingIOError when logging errors
Browse files Browse the repository at this point in the history
for example. job:
7697397
in test:
yuvalif-2024-05-08_09:55:02-rgw:notifications-wip-yuval-65337-distro-default-smithi

Signed-off-by: Yuval Lifshitz <ylifshit@ibm.com>
  • Loading branch information
yuvalif committed May 8, 2024
1 parent f4c6dfe commit 2831b23
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/test/rgw/bucket_notification/test_bn.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,35 @@
import boto.s3.tagging

# configure logging for the tests module
log = logging.getLogger(__name__)
class LogWrapper:
def __init__(self):
self.log = logging.getLogger(__name__)
self.errors = 0

def info(self, msg, *args, **kwargs):
try:
self.log.info(msg, *args, **kwargs)
except BlockingIOError:
self.errors += 1

def warning(self, msg, *args, **kwargs):
try:
self.log.warning(msg, *args, **kwargs)
except BlockingIOError:
self.errors += 1

def error(self, msg, *args, **kwargs):
try:
self.log.error(msg, *args, **kwargs)
except BlockingIOError:
self.errors += 1

def __del__(self):
if self.errors > 0:
self.log.error("%d logs were lost", self.errors)


log = LogWrapper()

TOPIC_SUFFIX = "_topic"
NOTIFICATION_SUFFIX = "_notif"
Expand Down Expand Up @@ -169,7 +197,7 @@ def __init__(self, addr, delay=0, cloudevents=False):
self.addr = addr
self.lock = threading.Lock()
ThreadingHTTPServer.__init__(self, addr, HTTPPostHandler)
log.info('http server created on %s', str(self.addr))
log.info('http server created on %s', self.addr)
self.proc = threading.Thread(target=self.run)
self.proc.daemon = True
self.proc.start()
Expand Down

0 comments on commit 2831b23

Please sign in to comment.