Skip to content

Commit 5dec9fe

Browse files
committed
Create two threads to handle server and client scopes
1 parent 210156b commit 5dec9fe

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • spawn/eigr/functions/actors/api

spawn/eigr/functions/actors/api/sdk.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import io
1616
import os
1717
import logging
18+
import uvicorn
1819
import threading
1920

2021

@@ -24,7 +25,6 @@ def create_app(controller: ActorController):
2425
@app.route('/api/v1/actors/actions', methods=["POST"])
2526
def action():
2627
data = request.data
27-
logging.info('Received Actor action request: %s', data)
2828

2929
actor_invocation_response = controller.handle_invoke(data)
3030

@@ -69,7 +69,7 @@ def host(self, address: str):
6969

7070
def port(self, port: int):
7171
"""Set the Network Port address."""
72-
self.__port = str(port)
72+
self.__port = port
7373
return self
7474

7575
def proxy_host(self, host: str):
@@ -105,19 +105,23 @@ def start(self):
105105

106106
server = threading.Thread(
107107
target=lambda: self.__start_server())
108+
client = threading.Thread(
109+
target=lambda: self.__register())
108110
logging.info("Starting Spawn on address %s", address)
109111
try:
110112
server.start()
111-
112-
# Invoke proxy for register ActorsEntity using Spawn protobuf types
113-
self.__register()
113+
client.start()
114+
server.join()
115+
client.join()
114116
except IOError as e:
115117
logging.error("Error on start Spawn %s", e.__cause__)
116118

117119
def __register(self):
118120
self.__controller.register()
119121

120122
def __start_server(self):
123+
124+
# uvicorn.run(self.__app, host=self.__host, port=self.__port)
121125
self.__app.run(
122126
host=self.__host,
123127
port=self.__port,

0 commit comments

Comments
 (0)