Python Twisted example with file descriptors

I want to use twisted to control communication through Linux channels (os.pipe ()) and fifos (os.mkfifo ()) between the main process and a set of slave processes. Although I'm sure you can use twisted ones for these types of file descriptors (after all, twisted ones are great for tcp sockets that * nix abstract in as file descriptors), I can't find any examples of this use. Does anyone have any links, code examples, or tips?

+3
source share
2 answers

It has nothing built in for asynchronous I / O. Someone wrote a libaio wrapper for him , but he was not touched for a long time, and I have no idea if he still works.

In the worst case scenario, you can use selectto see if there is anything readable, but that will not help you write.

-3
source

reactor.spawnProcess , . , ( stdin, stdout stderr), , - :

reactor.spawnProcess(protocol, executable, args,
                     childFDs={0: 'w', 1: 'r', 2: 'r', 3: 'r', 4: 'r'})

, , childDataReceived ProcessProtocol, , . . API spawnProcess.

Twisted , twisted.internet.stdio. stdiodemo.py stdin.py , .

+12

Source: https://habr.com/ru/post/1728562/


All Articles