This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def deco(f): | |
def wrapper(*args, **kwargs): | |
return ensureDeferred(f(*args, **kwargs)) | |
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sqrt, ceil | |
def shell(n): | |
a = int(ceil(sqrt(n))) | |
if a % 2 == 0: | |
a += 1 | |
c = a - 1 | |
d = c / 2 | |
return d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Unhandled Error | |
Traceback (most recent call last): | |
File "/Users/cougar/dev/buildbot/lib/python2.7/site-packages/twisted/python/log.py", line 84, in callWithLogger | |
return callWithContext({"system": lp}, func, *args, **kw) | |
File "/Users/cougar/dev/buildbot/lib/python2.7/site-packages/twisted/python/log.py", line 69, in callWithContext | |
return context.call({ILogContext: newCtx}, func, *args, **kw) | |
File "/Users/cougar/dev/buildbot/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext | |
return self.currentContext().callWithContext(ctx, func, *args, **kw) | |
File "/Users/cougar/dev/buildbot/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext | |
return func(*args,**kw) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
@pytest.fixture(scope="session", autouse=True) | |
def cleandir(tmpdir_factory, request): | |
tmpdir = tmpdir_factory.mktemp('data') | |
tmpdir.chdir() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if int(os.environ['TWISTED_NEWSTYLE']): | |
__metaclass__ = type | |
else: | |
from types import ClassType as __metaclass__ | |
class Deferred(_class_style): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if int(os.environ['TWISTED_NEWSTYLE']): | |
_class_style = object | |
else: | |
class _class_style: | |
pass | |
class Deferred(_class_style): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
from twisted.internet.defer import Deferred | |
def make_request(): | |
global resolver | |
print("making request") | |
resolver = Deferred() | |
return resolver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
StreamServerEndpointService( | |
serverFromString(reactor, os.environ.get("PORT", "tcp:8080")), | |
server.Site( | |
wsgi.WSGIResource( | |
reactor, | |
reactor.getThreadPool(), | |
WSGIApplication(gh_client, repo), | |
) | |
) | |
).setServiceParent(multi) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def poll_work(): | |
d = sqs.get_messages() | |
d.addCallback(process_messages) | |
d.addCallback(lambda _: poll_work()) |