Skip to content

No longer start stopped loops in LoopRunner to allow the use of asyncio.run #6163

Open
@fjetter

Description

@fjetter

The LoopRunner is accepting an event loop that has been created externally. This is a pattern that has been deprecated by CPython and our current implementation.

Requirements

  • LoopRunner no longer accepts event loops but creates and owns them itself.
  • There must still be a way to attach multiple servers (e.g. Scheduler and Client) to the same event loop.
  • The LoopRunner guarantees that all existing tornado.IOLoop instances are properly closed if the underlying asyncio event loop is stopped when loop is started and stopped without tornado API (e.g. asyncio.run).
  • It is not required to implement a deprecation cycle

More context in #6049

Implementation details

# Current interface

class LoopRunner:
    def __init__(self, loop=None, asynchronous=False):
        ...

    def start(self):
        ...
    
    def stop(self, timeout=10):
       ...

    def run_sync(self, func, *args, **kwargs):
        ...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions