Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Twisted protocol unregistering?

I've came up with problem regarding unregistering protocols from reactor in twisted while application is running.

I use hardware modems connected to PC by USB and that's why this scenario is so important for my solution. Has anyone an idea how to do it?

Greets, Chris

like image 680
Chris Ciesielski Avatar asked May 25 '09 12:05

Chris Ciesielski


1 Answers

When you first call reactor.listen on your protocol factory, it returns an object that implements IListeningPort, see http://twistedmatrix.com/documents/8.2.0/api/twisted.internet.interfaces.IListeningPort.html -- just save that object somewhere and when you want to stop listening on that protocol factori, call that object's stopListening method.

I assume that reactor.listen on the protocol factory is what you implicitly mean by "registering" a protocol (which logically should be what you're trying to undo by "unregistering" it), if you mean something else please clarify exactly how you "register a protocol" and we'll work out how to undo that!-)

like image 61
Alex Martelli Avatar answered Oct 02 '22 07:10

Alex Martelli