Skip to content

Commit cc73e07

Browse files
committed
Fix close bug in userver demo.
1 parent 7b7653e commit cc73e07

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

v3/as_drivers/client_server/heartbeat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ async def heartbeat(tms):
1414
elif platform == 'esp8266':
1515
from machine import Pin
1616
led = Pin(2, Pin.OUT, value=1)
17+
elif platform == 'esp32':
18+
# Some boards have an LED
19+
#from machine import Pin
20+
#led = Pin(2, Pin.OUT, value=1)
21+
return # Reference board has no LED
1722
elif platform == 'linux':
1823
return # No LED
1924
else:

v3/as_drivers/client_server/userver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ async def run_client(self, sreader, swriter):
4545
await sreader.wait_closed()
4646
print('Client {} socket closed.'.format(self.cid))
4747

48-
def close(self):
48+
async def close(self):
4949
print('Closing server')
5050
self.server.close()
5151
await self.server.wait_closed()
52-
print('Server closed')
52+
print('Server closed.')
5353

5454
server = Server()
5555
try:
5656
asyncio.run(server.run())
5757
except KeyboardInterrupt:
5858
print('Interrupted') # This mechanism doesn't work on Unix build.
5959
finally:
60-
server.close()
60+
asyncio.run(server.close())
6161
_ = asyncio.new_event_loop()

0 commit comments

Comments
 (0)