Skip to content

Commit de2e081

Browse files
miguelgrinbergdpgeorge
authored andcommitted
extmod/uasyncio: Fix start_server and wait_closed race condition.
This fix prevents server.wait_closed() from raising an AttributeError when trying to access server.task. This can happen if it is called immediately after start_server().
1 parent 525a920 commit de2e081

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

extmod/uasyncio/stream.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ async def _serve(self, cb, host, port, backlog):
112112
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
113113
s.bind(ai[-1])
114114
s.listen(backlog)
115-
self.task = core.cur_task
116115
# Accept incoming connections
117116
while True:
118117
try:
@@ -135,7 +134,7 @@ async def _serve(self, cb, host, port, backlog):
135134
# TODO could use an accept-callback on socket read activity instead of creating a task
136135
async def start_server(cb, host, port, backlog=5):
137136
s = Server()
138-
core.create_task(s._serve(cb, host, port, backlog))
137+
s.task = core.create_task(s._serve(cb, host, port, backlog))
139138
return s
140139

141140

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