MCPcopy Index your code
hub / github.com/RustPython/RustPython / write

Method write

Lib/_android_support.py:166–185  ·  view source on GitHub ↗
(self, prio, tag, message)

Source from the content-addressed store, hash-verified

164 self._prev_write_time = time()
165
166 def write(self, prio, tag, message):
167 # Encode null bytes using "modified UTF-8" to avoid them truncating the
168 # message.
169 message = message.replace(b"\x00", b"\xc0\x80")
170
171 with self._lock:
172 now = time()
173 self._bucket_level += (
174 (now - self._prev_write_time) * MAX_BYTES_PER_SECOND)
175
176 # If the bucket level is still below zero, the clock must have gone
177 # backwards, so reset it to zero and continue.
178 self._bucket_level = max(0, min(self._bucket_level, BUCKET_SIZE))
179 self._prev_write_time = now
180
181 self._bucket_level -= PER_MESSAGE_OVERHEAD + len(tag) + len(message)
182 if self._bucket_level < 0:
183 sleep(-self._bucket_level / MAX_BYTES_PER_SECOND)
184
185 self.android_log_write(prio, tag, message)

Callers 2

flushMethod · 0.45
writeMethod · 0.45

Calls 6

timeClass · 0.90
sleepFunction · 0.90
maxFunction · 0.85
minFunction · 0.85
lenFunction · 0.85
replaceMethod · 0.45

Tested by

no test coverage detected