mirror of
https://github.com/tiqi-group/pydase.git
synced 2026-02-10 12:28:42 +01:00
updates server to use asyncio.run
This commit is contained in:
@@ -184,23 +184,8 @@ class Server:
|
|||||||
Initializes the asyncio event loop and starts the server.
|
Initializes the asyncio event loop and starts the server.
|
||||||
|
|
||||||
This method should be called to start the server after it's been instantiated.
|
This method should be called to start the server after it's been instantiated.
|
||||||
|
|
||||||
Raises
|
|
||||||
------
|
|
||||||
Exception
|
|
||||||
If there's an error while running the server, the error will be propagated
|
|
||||||
after the server is shut down.
|
|
||||||
"""
|
"""
|
||||||
try:
|
asyncio.run(self.serve())
|
||||||
self._loop = asyncio.get_running_loop()
|
|
||||||
except RuntimeError:
|
|
||||||
self._loop = asyncio.new_event_loop()
|
|
||||||
asyncio.set_event_loop(self._loop)
|
|
||||||
try:
|
|
||||||
self._loop.run_until_complete(self.serve())
|
|
||||||
except Exception:
|
|
||||||
self._loop.run_until_complete(self.shutdown())
|
|
||||||
raise
|
|
||||||
|
|
||||||
async def serve(self) -> None:
|
async def serve(self) -> None:
|
||||||
process_id = os.getpid()
|
process_id = os.getpid()
|
||||||
|
|||||||
Reference in New Issue
Block a user