Skip to content

Instantly share code, notes, and snippets.

@exarkun
Created July 24, 2017 16:17
Show Gist options
  • Save exarkun/807542acac6504b20884a94832b34ee5 to your computer and use it in GitHub Desktop.
Save exarkun/807542acac6504b20884a94832b34ee5 to your computer and use it in GitHub Desktop.
exarkun@baryon:~$ cat > /tmp/sscce.py
from twisted.internet import reactor
from twisted.internet.defer import Deferred, inlineCallbacks
from twisted.internet.task import deferLater
from twisted.internet.endpoints import serverFromString
from twisted.internet.protocol import Factory
from twisted.protocols.basic import LineReceiver
class _DomainLineReceiver(LineReceiver):
delimiter = "\n"
def lineReceived(self, line):
deferLater(reactor, 1, self._output)
def _output(self):
print "PRINTED"
self.sendLine("HEY COOL SILENT FAILURE")
endpoint = serverFromString(reactor, "stdio:")
endpoint.listen(Factory.forProtocol(_DomainLineReceiver))
reactor.run()
exarkun@baryon:~$ python /tmp/sscce.py
hello
PRINTED
HEY COOL SILENT FAILURE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment