Questions tagged [python-trio]

Trio is a Python package for async concurrency and I/O that's obsessed with usability and correctness

Official web site

87 questions
0
votes
1 answer

How to combine streams in anyio?

How to iterate over multiple steams at once in anyio, interleaving the items as they appear? Let's say, I want a simple equivalent of annotate-output. The simplest I could make is #!/usr/bin/env python3 import dataclasses from collections.abc…
HoverHell
  • 4,739
  • 3
  • 21
  • 23
0
votes
1 answer

Trio WebSocket does not send bytes

The trio documentation recommends the trio-websocket package as a way to handle sockets. I used this recommendation and I'm trying to configure it to work with the server built on the starlette WebSocketEndpoint. But for some reason, when I try to…
0
votes
2 answers

Trio + PyQT5 in one program?

How can I use trio in conjunction with PyQT5? The thing is that my program has interface written using PyQT5, and now I need to run eventloop trio, to work with the network, because I use trio WebSocket to connect to the server. I read that I should…
0
votes
1 answer

python trio interrogate state of child_tasks

with access to a trio.Nursery instance nursery, how may I print state of all nursery.child_tasks, specifically which have not yet exited? I'm not understanding, reading docs & the trio NurseryManager code: how "nested child" tasks might be…
some bits flipped
  • 2,592
  • 4
  • 27
  • 42
0
votes
1 answer

catch a break in trio async generator

I have a strange error with an asynchronous trio loop. When I interrupt the loop with break during iteration, I expected the print statement "exit 2" to be printed before the statement "--- Hello ---". But when I run this example, the code after the…
Phil997
  • 575
  • 5
  • 15
0
votes
1 answer

How to use trio_asyncio with legacy sync code in python

I have legacy python application which is synchronous. I started to use async code inside this application in this way (simplified): async def loader(): async with trio.open_nursery() as nursery: # some async tasks started here await…
eNca
  • 1,043
  • 11
  • 21
0
votes
1 answer

uwsgi worker hangs on exit, but only if it used async trio module

I have a Django site that uses the trio_cdp package to generate PDFs using a headless Google Chrome. This package is async, but my Django project is sync, so it has to run inside trio.run() It's also using uwsgi locks so that only one client can…
Mark P
  • 173
  • 2
  • 5
0
votes
1 answer

Getting duplicate packets from AF_PACKET socket

I'm having an odd issue with an AF_PACKET socket and I was wondering if it was due to possible misuse of trio on my behalf, or something else. I'm writing a TCP SYN port scanner with the goal of making it highly performant. Suppose that I want to…
adder
  • 3,512
  • 1
  • 16
  • 28
0
votes
1 answer

Reliably detect that no more packets are coming

I'm writing a TCP SYN port scanner. I spin up 15 tasks that each send 64K / 15 packets to 64K ports, and I have a receiver that sits in a loop and prints the responses. However, some of the packets don't make their way back, making the receiver wait…
adder
  • 3,512
  • 1
  • 16
  • 28
0
votes
0 answers

Cannot keyboard interrupt trio/asyncio program (ctrl+c) to exit

The following code works, but fails to exit upon CTRL+c Can anyone explain why, and how to fix? It's asyncio code, but I'm using trio-asyncio (forward planning) to allow me to also use trio code. #!.venv/bin/python import asyncio import…
P i
  • 29,020
  • 36
  • 159
  • 267
0
votes
2 answers

How can I execute a function on a CPU core, and get a callback when it has completed?

How can I execute a function on a CPU core, and get a callback when it has completed? Context I'm recieving a stream: symbols = ['ABC', 'DFG', ...] # 52 of these handlers = { symbol: Handler(symbol) for symbol in symbols } async for symbol,…
P i
  • 29,020
  • 36
  • 159
  • 267
0
votes
1 answer

I am using Trio and how do I get the IP address of an already open socket?

This is a simple problem and Im sure there is an solution. I am trying to get the IP address of a socket which I have already connected to. I used trio.serve_tcp(handler, port) to create an server and now I want to know if someone is making…
Kenggi Peters
  • 31
  • 1
  • 5
0
votes
2 answers

what is the exact version of python-trio echo server - multiple client in asyncio?

I am trying to convert the following echo server IRC alike chat terminal into asyncio , but I don't think too much information about trio since it's new, but what is the translation of this to asyncio? import trio from itertools import count from…
etyzz
  • 55
  • 6
0
votes
1 answer

I got a trio input function from a friend and it's trying to use trio.lowleve.FdStream, however I can't find it

I'm getting this error: AttributeError: module 'trio.lowlevel' has no attribute 'FdStream'. FdStream isn't in the trio code on git nor in my installation. Is there an alternative to this, or is there a different version I did't find?
merolé
  • 3
  • 3
0
votes
1 answer

Right way to terminate a trio program without BrokenResourceError

My app follows a Producer and Consumer pattern. There's a Producer, 2 task (A, B), and a Consumer. Producer reads an sql table and outputs to A & B. They in turn performs some task on that output and sends to Consumer. Consumer reads from A & B and…
Tinker
  • 4,165
  • 6
  • 33
  • 72