Skip to content

Instantly share code, notes, and snippets.

if int(os.environ['TWISTED_NEWSTYLE']):
__metaclass__ = type
else:
from types import ClassType as __metaclass__
class Deferred(_class_style):
pass
if int(os.environ['TWISTED_NEWSTYLE']):
_class_style = object
else:
class _class_style:
pass
class Deferred(_class_style):
pass
use std::thread;
use std::sync::Arc;
fn main() {
let pass = Arc::new("test".to_string());
thread::spawn({let pass = pass.clone(); move || println!("{}", pass)});
thread::spawn(move || println!("{}", pass));
}
from __future__ import print_function
from twisted.internet.defer import Deferred
def make_request():
global resolver
print("making request")
resolver = Deferred()
return resolver
StreamServerEndpointService(
serverFromString(reactor, os.environ.get("PORT", "tcp:8080")),
server.Site(
wsgi.WSGIResource(
reactor,
reactor.getThreadPool(),
WSGIApplication(gh_client, repo),
)
)
).setServiceParent(multi)
def poll_work():
d = sqs.get_messages()
d.addCallback(process_messages)
d.addCallback(lambda _: poll_work())
from hypothesis.strategies import *
def subset_strat(strategies):
def build(keys):
return fixed_dictionaries({key: strategies[key] for key in keys})
return sets(sampled_from(strategies.keys())).flatmap(build)
if __name__ == "__main__":
print(subset_strat({"abc": integers(), "def": text()}).example())
@tomprince
tomprince / gist:61c5cfeaa9904646f60d
Created September 30, 2015 17:06
Eliot Journal failures.
eliot.tests.test_journald
JournaldDestinationTests
test_action_type ... [OK]
test_critical_priority ... [OK]
test_error_priority ... [FAIL]
test_identifier ... [FAIL]
test_info_priorities ... [FAIL]
test_json ... [FAIL]
test_message_type ... [FAIL]
test_no_type ... [FAIL]
@tomprince
tomprince / gist:e58d041cc81ac004e635
Last active August 29, 2015 14:22
Effect using mockup.
class Request(object):
"Description of an HTTP request."
def engined(f):
"Turn an effect using function into one that uses a specific performer."
@wraps(f)
def wrapper(*args, **kwargs, engine=blocking_engine):
effect = f(*args, **kwargs)
result = engine(effect)
DEPRECATION: --download-cache has been deprecated and will be removed in the future. Pip now automatically uses and configures its cache.
Collecting pytest
Getting page https://pypi.python.org/simple/pytest/
1 location(s) to search for versions of pytest:
* https://pypi.python.org/simple/pytest/
Skipping link file:///home/tomprince/.cache/pip/wheelhouse (from -f); not a file
Getting page https://pypi.python.org/simple/pytest/
Analyzing links from page https://pypi.python.org/simple/pytest/
Found link https://pypi.python.org/packages/source/p/pytest/pytest-2.0.0.zip#md5=f07c521dfd5a540f3dfea1846e58dab7 (from https://pypi.python.org/simple/pytest/), version: 2.0.0
Found link https://pypi.python.org/packages/source/p/pytest/pytest-2.0.1.zip#md5=0667d82556db906a7429171589d95e4d (from https://pypi.python.org/simple/pytest/), version: 2.0.1