MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / loop

Method loop

example_code/item_076.py:312–324  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

310
311 print("Example 18")
312 async def loop(self): # Changed
313 while command := await self.receive(): # Changed
314 match command.split(" "):
315 case "PARAMS", lower, upper:
316 self.set_params(lower, upper)
317 case ["NUMBER"]:
318 await self.send_number() # Changed
319 case "REPORT", decision:
320 self.receive_report(decision)
321 case ["CLEAR"]:
322 self.clear_state()
323 case _:
324 raise UnknownCommandError(command)
325
326
327 print("Example 19")

Callers 1

handle_async_connectionFunction · 0.95

Calls 6

set_paramsMethod · 0.95
send_numberMethod · 0.95
receive_reportMethod · 0.95
clear_stateMethod · 0.95
UnknownCommandErrorClass · 0.85
receiveMethod · 0.45

Tested by

no test coverage detected