Skip to content

Commit

Permalink
Update controller.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Feb 4, 2024
1 parent 77ffeb0 commit 98b7bc8
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions aiosmtpd/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def cancel_tasks(self, stop_loop: bool = True):
self.loop.stop()
try:
_all_tasks = asyncio.all_tasks # pytype: disable=module-attr
except AttributeError: # pragma: py-gt-36
except AttributeError:
_all_tasks = asyncio.Task.all_tasks # pytype: disable=attribute-error
for task in _all_tasks(self.loop):
# This needs to be invoked in a thread-safe way
Expand Down Expand Up @@ -246,13 +246,8 @@ class (it's lazy initialization, done only on initial connection).
def _run(self, ready_event: threading.Event) -> None:
asyncio.set_event_loop(self.loop)
try:
# Need to do two-step assignments here to ensure IDEs can properly
# detect the types of the vars. Cannot use `assert isinstance`, because
# Python 3.6 in asyncio debug mode has a bug wherein CoroWrapper is not
# an instance of Coroutine
self.server_coro = self._create_server()
srv: AsyncServer = self.loop.run_until_complete(self.server_coro)
self.server = srv
self.server = self.loop.run_until_complete(self.server_coro)
except Exception as error: # pragma: on-wsl
# Usually will enter this part only if create_server() cannot bind to the
# specified host:port.
Expand Down Expand Up @@ -362,13 +357,8 @@ def begin(self):
Does NOT actually start the event loop itself.
"""
asyncio.set_event_loop(self.loop)
# Need to do two-step assignments here to ensure IDEs can properly
# detect the types of the vars. Cannot use `assert isinstance`, because
# Python 3.6 in asyncio debug mode has a bug wherein CoroWrapper is not
# an instance of Coroutine
self.server_coro = self._create_server()
srv: AsyncServer = self.loop.run_until_complete(self.server_coro)
self.server = srv
self.server = self.loop.run_until_complete(self.server_coro)

async def finalize(self):
"""
Expand Down

0 comments on commit 98b7bc8

Please sign in to comment.