mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-23 01:20:03 +02:00
updates server to use asyncio.run
This commit is contained in:
parent
f69723dd58
commit
ca41e12014
@ -184,23 +184,8 @@ class Server:
|
||||
Initializes the asyncio event loop and starts the server.
|
||||
|
||||
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:
|
||||
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
|
||||
asyncio.run(self.serve())
|
||||
|
||||
async def serve(self) -> None:
|
||||
process_id = os.getpid()
|
||||
|
Loading…
x
Reference in New Issue
Block a user