Skip to content

Commit 9a72e29

Browse files
committed
uasyncio: Consistently use "if DEBUG and __debug__:" stanza.
To make sure this module can work without logging module imported, just like uasyncio.core was made to.
1 parent 91d9c16 commit 9a72e29

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

uasyncio/uasyncio/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def readexactly(self, n):
100100
return buf
101101

102102
def readline(self):
103-
if __debug__:
103+
if DEBUG and __debug__:
104104
log.debug("StreamReader.readline()")
105105
buf = b""
106106
while True:
@@ -156,7 +156,7 @@ def awrite(self, buf):
156156
sz -= res
157157
yield IOWrite(self.s)
158158
#assert s2.fileno() == self.s.fileno()
159-
if __debug__:
159+
if DEBUG and __debug__:
160160
log.debug("StreamWriter.awrite(): can write more")
161161

162162
def aclose(self):
@@ -182,7 +182,7 @@ def open_connection(host, port):
182182
except OSError as e:
183183
if e.args[0] != uerrno.EINPROGRESS:
184184
raise
185-
if __debug__:
185+
if DEBUG and __debug__:
186186
log.debug("open_connection: After connect")
187187
yield IOWrite(s)
188188
# if __debug__:
@@ -193,7 +193,8 @@ def open_connection(host, port):
193193

194194

195195
def start_server(client_coro, host, port, backlog=10):
196-
log.debug("start_server(%s, %s)", host, port)
196+
if DEBUG and __debug__:
197+
log.debug("start_server(%s, %s)", host, port)
197198
s = _socket.socket()
198199
s.setblocking(False)
199200

@@ -203,10 +204,10 @@ def start_server(client_coro, host, port, backlog=10):
203204
s.bind(addr)
204205
s.listen(backlog)
205206
while True:
206-
if __debug__:
207+
if DEBUG and __debug__:
207208
log.debug("start_server: Before accept")
208209
yield IORead(s)
209-
if __debug__:
210+
if DEBUG and __debug__:
210211
log.debug("start_server: After iowait")
211212
s2, client_addr = s.accept()
212213
s2.setblocking(False)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy