first commit
This commit is contained in:
34
python/test_server.py
Executable file
34
python/test_server.py
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (c) 2023 - present, Anton Anikin <anton@anikin.xyz>
|
||||
# All rights reserved.
|
||||
|
||||
import numpy as np
|
||||
import sys
|
||||
|
||||
from ipc import Ipc
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
assert len(sys.argv) >= 3
|
||||
|
||||
ipc_name = sys.argv[1]
|
||||
is_server = sys.argv[2] == "1"
|
||||
|
||||
print("[python] pre-start")
|
||||
ipc = Ipc(ipc_name, is_server)
|
||||
print("[python] start")
|
||||
|
||||
while True:
|
||||
value = ipc.read_int_opt()
|
||||
if value is None:
|
||||
break
|
||||
|
||||
print(f"[python] read int({value})")
|
||||
|
||||
# result = value * value
|
||||
result = np.sqrt(value)
|
||||
ipc.write_double(result)
|
||||
print(f"[python] write double({result:.2e})")
|
||||
|
||||
print("[python] finish the work\n");
|
||||
Reference in New Issue
Block a user