Skip to content

Commit

Permalink
Merge pull request #3164 from graingert/patch-1
Browse files Browse the repository at this point in the history
make existing_loop check atomic
  • Loading branch information
bdarnell committed Jun 21, 2022
2 parents 1de5e68 + a619885 commit 7a80716
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tornado/platform/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,12 @@ def initialize( # type: ignore
pass

# Make sure we don't already have an IOLoop for this asyncio loop
if asyncio_loop in IOLoop._ioloop_for_asyncio:
existing_loop = IOLoop._ioloop_for_asyncio[asyncio_loop]
existing_loop = IOLoop._ioloop_for_asyncio.setdefault(asyncio_loop, self)
if existing_loop is not self:
raise RuntimeError(
f"IOLoop {existing_loop} already associated with asyncio loop {asyncio_loop}"
)

IOLoop._ioloop_for_asyncio[asyncio_loop] = self

self._thread_identity = 0

super().initialize(**kwargs)
Expand Down

0 comments on commit 7a80716

Please sign in to comment.