You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fd_endpoint.py 822B

123456789101112131415161718192021222324
  1. import socket
  2. from twisted.internet import endpoints
  3. from twisted.internet.interfaces import IStreamServerEndpointStringParser
  4. from twisted.plugin import IPlugin
  5. from zope.interface import implementer
  6. @implementer(IPlugin, IStreamServerEndpointStringParser)
  7. class _FDParser(object):
  8. prefix = "fd"
  9. def _parseServer(self, reactor, fileno, domain=socket.AF_INET):
  10. fileno = int(fileno)
  11. return endpoints.AdoptedStreamServerEndpoint(reactor, fileno, domain)
  12. def parseStreamServer(self, reactor, *args, **kwargs):
  13. # Delegate to another function with a sane signature. This function has
  14. # an insane signature to trick zope.interface into believing the
  15. # interface is correctly implemented.
  16. return self._parseServer(reactor, *args, **kwargs)
  17. parser = _FDParser()