Concurrency and Modules
Client and Server Modules
A larger program often splits client code from server code. This page renders the files as separate source and replay blocks so each file can keep its own panel.
Server Module
task_client.py
command =
request = {"command": command, "user": "reader"}
print("send=" + request["command"])
print("user=" + request["user"])
command =
request = {"command": command, "user": "reader"}
print("send=" + request["command"])
print("user=" + request["user"])
command =
request = {"command": command, "user": "reader"}
print("send=" + request["command"])
print("user=" + request["user"])
task_server.py
command =
def handle(command):
if command == "ping":
return "pong"
if command == "count":
return "items=2"
return "ready"
response = handle(command)
print("response=" + response)
command =
def handle(command):
if command == "ping":
return "pong"
if command == "count":
return "items=2"
return "ready"
response = handle(command)
print("response=" + response)
command =
def handle(command):
if command == "ping":
return "pong"
if command == "count":
return "items=2"
return "ready"
response = handle(command)
print("response=" + response)
module boundary
One module can prepare a request while another module handles the command. Replay keeps each source file separate.