Skip to content

Commit

Permalink
Get some requests going!
Browse files Browse the repository at this point in the history
  • Loading branch information
Moosems committed Sep 5, 2024
1 parent b871c90 commit 9a460be
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
38 changes: 26 additions & 12 deletions collegamento/simple_client_server/new_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,24 @@ def request(

id: int = self.create_message_id()

# self.current_ids[command] = id
# final_request: Request = {
# "id": id,
# "type": "request",
# "command": command,
# }
# final_request.update(request_details) # type: ignore
# self.logger.debug(f"Request created: {final_request}")
final_request: Request = {
"id": id,
"type": "request",
"command": command,
}
final_request.update(request_details)

if self.commands[command][1]:
self.current_ids[id] = command

self.current_ids[command] = id
self.logger.debug(f"Request created: {final_request}")

# self.request_queue.put(final_request)
# self.logger.info("Message sent")
self.request_queue.put(final_request)
self.logger.info("Message sent")

if self.commands[command][1]:
return id

def kill_IPC(self):
"""Kills the internal Process and frees up some storage and CPU that may have been used otherwise - external API"""
Expand All @@ -363,8 +369,16 @@ def __del__(self):
from test_func import foo

# Mini tests
Client({"foo": (foo, True)})
x = Client({"foo": foo})
Client({"foo": foo})
x = Client({"foo": (foo, True), "foo2": foo})
id1 = x.request({"command": "foo"})
id2 = x.request({"command": "foo"})
id3 = x.request({"command": "foo2"})
id4 = x.request({"command": "foo2"}) # If you see four "Foo called"'s, thats bad news bears
assert id1 is not None
assert id2 is not None
assert id3 is None
assert id4 is None
sleep(1)
x.create_server()
Client()
Expand Down
4 changes: 2 additions & 2 deletions collegamento/simple_client_server/test_func.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def foo(*args):
return
def foo(server, request):
print("Foo called", request["id"])

0 comments on commit 9a460be

Please sign in to comment.