Skip to content

Instantly share code, notes, and snippets.

View markrwilliams's full-sized avatar

Mark Williams markrwilliams

View GitHub Profile
import pytest
from twisted.internet import defer
def successResultOf(d):
completed = []
d.addCallback(completed.append)
assert completed, "{!r} not yet fired".format(d)
diff --git a/src/twisted/internet/tcp.py b/src/twisted/internet/tcp.py
index dc798f08c..4550c0e03 100644
--- a/src/twisted/internet/tcp.py
+++ b/src/twisted/internet/tcp.py
@@ -11,6 +11,9 @@ End users shouldn't use this module directly - use the reactor APIs instead.
from __future__ import division, absolute_import
# System Imports
+import traceback
+import weakref
from twisted.logger import globalLogBeginner, textFileLogObserver, Logger
from twisted.internet.defer import inlineCallbacks
from twisted.internet.task import react
from twisted.python import failure
from twisted.internet import protocol, endpoints
import sys
import twisted
print "Twisted:", twisted.__version__
log = Logger()
from __future__ import print_function
import sys
import treq
from twisted.internet.task import react
def main(reactor, domain):
import eliot
import sys
eliot.to_file(sys.stdout)
with eliot.start_action(action_type=u"task"):
eliot.Message.log(key=u"value")
import asyncio
def adapt(the_future):
try:
print("*** result before")
the_future.result()
except:
print("*** exception before")
the_future.exception()
@markrwilliams
markrwilliams / .gitignore
Last active March 19, 2017 07:48
OpenSSL incomplete handshake SSL_ERROR_SSL -> SSL_ERROR_SYSCALL
client
@markrwilliams
markrwilliams / getfile.py
Created May 5, 2017 19:19
A basic FileSender example
import sys
from twisted.protocols import basic
from twisted.internet import defer, endpoints, protocol, task
class GetFileProtocol(basic.LineReceiver):
delimiter = '\n'
def lineReceived(self, line):
parts = line.split(None, 1)
import unittest
from hypothesis import given, strategies as st
class ComparisonTests(unittest.TestCase):
def assertNonesCauseTypeError(self, first, second):
try:
first > second