Server isolation and detailed errors
Isolated the JsonServer to server.py inside protocols/json Added specific errors for server startup timeout and server startup failed Refactored errors for Core to CoreError generic and refactored StateError to CoreStateMismatchError derived from CoreError
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
from time import sleep
|
||||
from dynalab_core import Core
|
||||
from dynalab_core.config import CoreConfig
|
||||
|
||||
|
||||
config = CoreConfig(port=8765)
|
||||
print(config)
|
||||
dl_core = Core(config)
|
||||
dl_core.start()
|
||||
print("started")
|
||||
|
||||
try:
|
||||
while True:
|
||||
dl_core.wait(1)
|
||||
print("waiting")
|
||||
except KeyboardInterrupt:
|
||||
dl_core.stop()
|
||||
@@ -0,0 +1,20 @@
|
||||
import asyncio
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
reader, writer = await asyncio.open_connection(
|
||||
host="127.0.0.1",
|
||||
port=8765,
|
||||
)
|
||||
|
||||
print("Connected")
|
||||
|
||||
try:
|
||||
await asyncio.sleep(10)
|
||||
finally:
|
||||
writer.close()
|
||||
await writer.wait_closed()
|
||||
print("Disconnected")
|
||||
|
||||
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user