Re: How to use the TimeoutProtocol policy?

"L. Daniel Burr" <[email protected]>
Newsgroups gmane.comp.python.twisted
Message-ID <[email protected]>
Hi Martin,

On June 14, 2018 at 8:29:45 AM, Martin van Es ([email protected]) wrote:

Hi,

I'm trying to timeout a really simple LineReceiver protocol.

It's function is to connect to a daemon, receive a line that's to be
displayed to an end-user upon which the user should undertake some
action. The action will trigger a second line (fail/success) at which
point the daemon will close the connection. If, however, the end-user
does not follow-up on the first challenge I want the script to timeout
with a failed result.

Now, I have the LineReceiver do exactly what I want, but I can't for
the life of me understand how I should "wrap" it in the TimoutProtocol
so that it disconnects after a couple of seconds?

This is my Factory:
class WebSSOFactory(ClientFactory):
pamh = None
client = None


I think one problem here is that your WebSSOFactory is not a TimeoutFactory (https://twistedmatrix.com/documents/current/api/twisted.protocols.policies.TimeoutFactory.html).

You have to pass a TimeoutFactory to the TimeoutProtocol in order for it to work with the LineReceiver you are wrapping, otherwise the timeout value will not be set; a regular Factory’s buildProtocol method would not know that it needs to pass the timeout to the TimeoutProtocol.

Hope this helps,

Daniel

_______________________________________________
Twisted-Python mailing list
[email protected]
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.