openlawlibrary / pygls

A pythonic generic language server
https://pygls.readthedocs.io/en/latest/
Apache License 2.0
568 stars 103 forks source link

Ensure that `pygls.Server` uses the event loop it is given #336

Closed alcarney closed 1 year ago

alcarney commented 1 year ago

Description (e.g. "Related to ...", etc.)

Before this commit pygls would override the event loop for the current thread even when given an existing loop to use.

Now pygls will rely on asyncio.new_event_loop to create the appropriate event loop for the platform and only call it when loop=None

This commit also introduces the _own_loop flag which is used to make sure pygls does not close an event loop it does not own.

Related: #334

Code review checklist (for code reviewer to complete)