You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allowing multiple requests of the same command would make the framework much more flexible and I believe this could be done without a major API change. If this is allowed, the user would have to keep track of what id's correspond to what requests for commands allowing multiple requests. They would still run concurrently but perhaps this could be changed to have flags that determine what settings are applied? To modify the simple example, it would likely look similar to this:
fromtimeimportsleepfromcollegamentoimport (
USER_FUNCTION,
Request,
Response,
SimpleClient,
SimpleServer,
)
deffoo(server: "SimpleServer", bar: Request) ->bool:
ifbar["command"] =="test":
returnTruereturnFalsedefmain():
commands: dict[str, USER_FUNCTION] = {"test": (foo, False)} # bool indicates whether command is only newest. Defaults to True (and not needing a bool). Maybe in the future this will use flagscontext=SimpleClient(commands)
id1=context.request({"command": "test"}) # Only returns an id int if the command allows multiple at onceid2=context.request({"command": "test"})
sleep(1)
# This is where the API could make one of two changes: Option one is that it doesn't and it simply returns a list of new answers:output: list[Response] |None=context.get_response("test")
iflen(output) <2:
print("Yippee! It worked!")
else:
print("Hmm, that didn't work", output)
# Or, alternatively, we could request by id (raises error if id is not in system and still accepts string commands):output1: Response|None=context.get_response(id1)
output2: Response|None=context.get_response(id2)
if (output1andoutput2):
print("Yippee! It worked!")
else:
print("Hmm, that didn't work", output)
context.kill_IPC()
if__name__=="__main__":
main()
The text was updated successfully, but these errors were encountered:
I think I like the second option more because it keeps the API much closer to what it was before. Implementation-wise we could internally treat all commands like they are multiple run commands half the time. What I mean by this is we keep a list of commands that allow multiple requests at once, the newest responses dict always corresponds to a list of Response's, and current ids has all the normal single commands along with ids as mappings. This would look as follows:
Feature report:
Allowing multiple requests of the same command would make the framework much more flexible and I believe this could be done without a major API change. If this is allowed, the user would have to keep track of what id's correspond to what requests for commands allowing multiple requests. They would still run concurrently but perhaps this could be changed to have flags that determine what settings are applied? To modify the simple example, it would likely look similar to this:
The text was updated successfully, but these errors were encountered: