kopia lustrzana https://github.com/micropython/micropython-lib
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.pull/68/merge
rodzic
91d9c168b8
commit
9a72e29564
|
@ -100,7 +100,7 @@ class StreamReader:
|
||||||
return buf
|
return buf
|
||||||
|
|
||||||
def readline(self):
|
def readline(self):
|
||||||
if __debug__:
|
if DEBUG and __debug__:
|
||||||
log.debug("StreamReader.readline()")
|
log.debug("StreamReader.readline()")
|
||||||
buf = b""
|
buf = b""
|
||||||
while True:
|
while True:
|
||||||
|
@ -156,7 +156,7 @@ class StreamWriter:
|
||||||
sz -= res
|
sz -= res
|
||||||
yield IOWrite(self.s)
|
yield IOWrite(self.s)
|
||||||
#assert s2.fileno() == self.s.fileno()
|
#assert s2.fileno() == self.s.fileno()
|
||||||
if __debug__:
|
if DEBUG and __debug__:
|
||||||
log.debug("StreamWriter.awrite(): can write more")
|
log.debug("StreamWriter.awrite(): can write more")
|
||||||
|
|
||||||
def aclose(self):
|
def aclose(self):
|
||||||
|
@ -182,7 +182,7 @@ def open_connection(host, port):
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.args[0] != uerrno.EINPROGRESS:
|
if e.args[0] != uerrno.EINPROGRESS:
|
||||||
raise
|
raise
|
||||||
if __debug__:
|
if DEBUG and __debug__:
|
||||||
log.debug("open_connection: After connect")
|
log.debug("open_connection: After connect")
|
||||||
yield IOWrite(s)
|
yield IOWrite(s)
|
||||||
# if __debug__:
|
# if __debug__:
|
||||||
|
@ -193,7 +193,8 @@ def open_connection(host, port):
|
||||||
|
|
||||||
|
|
||||||
def start_server(client_coro, host, port, backlog=10):
|
def start_server(client_coro, host, port, backlog=10):
|
||||||
log.debug("start_server(%s, %s)", host, port)
|
if DEBUG and __debug__:
|
||||||
|
log.debug("start_server(%s, %s)", host, port)
|
||||||
s = _socket.socket()
|
s = _socket.socket()
|
||||||
s.setblocking(False)
|
s.setblocking(False)
|
||||||
|
|
||||||
|
@ -203,10 +204,10 @@ def start_server(client_coro, host, port, backlog=10):
|
||||||
s.bind(addr)
|
s.bind(addr)
|
||||||
s.listen(backlog)
|
s.listen(backlog)
|
||||||
while True:
|
while True:
|
||||||
if __debug__:
|
if DEBUG and __debug__:
|
||||||
log.debug("start_server: Before accept")
|
log.debug("start_server: Before accept")
|
||||||
yield IORead(s)
|
yield IORead(s)
|
||||||
if __debug__:
|
if DEBUG and __debug__:
|
||||||
log.debug("start_server: After iowait")
|
log.debug("start_server: After iowait")
|
||||||
s2, client_addr = s.accept()
|
s2, client_addr = s.accept()
|
||||||
s2.setblocking(False)
|
s2.setblocking(False)
|
||||||
|
|
Ładowanie…
Reference in New Issue