2
2
3
3
import logging
4
4
from threading import Thread
5
+ from types import TracebackType
6
+ from typing import Optional , Type
5
7
6
8
from mozlog import commandline , stdadapter , set_default_logger
7
9
from mozlog .structuredlog import StructuredLogger , log_levels
@@ -77,7 +79,7 @@ def __init__(self, queue, level=logging.NOTSET):
77
79
78
80
def createLock (self ):
79
81
# The queue provides its own locking
80
- self .lock = NullLock ()
82
+ self .lock = NullRLock ()
81
83
82
84
def emit (self , record ):
83
85
msg = self .format (record )
@@ -91,18 +93,22 @@ def emit(self, record):
91
93
92
94
93
95
94
- class NullLock :
95
- def acquire (self ):
96
- pass
96
+ class NullRLock :
97
+ """Implementation of the threading.RLock API that doesn't actually acquire a lock,
98
+ for use in cases where there is another mechanism to provide the required
99
+ invariants."""
97
100
98
- def release (self ) :
99
- pass
101
+ def acquire (self , blocking : bool = True , timeout : float = - 1 ) -> bool :
102
+ return True
100
103
101
- def __enter__ (self ):
102
- return self
104
+ def release (self ) -> None :
105
+ return None
103
106
104
- def __exit__ (self , * args , ** kwargs ):
105
- pass
107
+ def __enter__ (self ) -> bool :
108
+ return True
109
+
110
+ def __exit__ (self , t : Optional [Type [BaseException ]], v : Optional [BaseException ], tb : Optional [TracebackType ]) -> None :
111
+ return None
106
112
107
113
108
114
class LogQueueThread (Thread ):
0 commit comments