Donovan
Donovan

Reputation: 6122

Twisted threaded tcp client


I am trying to write a simple TCPServer and a client with Twisted python. Everything is working well; but, there is a way to defer some tasks to different threads? For example, is it possible to do:

simultaneously?
Which are best practices?

Thank you for your help.
—Donovan

Upvotes: 1

Views: 603

Answers (1)

Jean-Paul Calderone
Jean-Paul Calderone

Reputation: 48335

Threads are one implementation strategy for doing these things simultaneously. Twisted generally goes with another strategy - non-blocking I/O and an event multiplexer (eg select(2)).

If you want to handle input from stdin while you have a TCPServer running, all that means is that you want to use Twisted's APIs for reading from stdin, just like you're using Twisted's APIs for handling network connections.

See twisted.internet.stdio.StandardIO for that.

Upvotes: 2

Related Questions