how to structure beginning and ending synchronous calls using trio?

My ask is for structured trio pseudo-code (actual trio function-calls, but dummy worker-does-work-here fill-in) so I can understand and try out good flow-control practices for switching between synchronous and asynchronous processes.I want to do the following...load a file of json-data into a data-dictaside: the data-dict looks like { 'key_a': {(info_dict_a)}, 'key_b': {info_dict_b} }have each of n-workers... access that data-dict to find the next record-to-process info-dictprepare some data from the record-being-processed and post the data to ...Read more

Combining trio and flask

I'm trying to make an HTTP API that can create and destroy concurrent tasks that open TCP connections to remote servers streaming ~15-second data. I'll have to figure out how to handle the data later. For now I just print it.In the example below, I can create multiple TCP connections by navigating to http://192.168.1.1:5000/addconnection.Questions:1) Is this approach reasonable? I think Flask may be creating a new thread for each /addconnection request. I'm not sure what performance limits I'll hit doing that.2) Is it possible to keep track of ...Read more

Future/Promise like stuff for Trio in Python?

Say I have a class Messenger which is responsible for sending and receiving messages. Now I have a service that sends out requests and waits for responses via it, matching each pair with an id field in the message. In asyncio I would do:class Service: ... async def request(self, req): new_id = self._gen_id() req.id = new_id fu = asyncio.Future() self._requests[new_id] = fu await self._messenger.send(req) return await fu def handle_response(self, res): try: fu = self._requests.pop(res.req_id) except KeyError: ...Read more