Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bdarnell
bdarnell / coop.py
Created February 17, 2014 19:11
Sketches of potential HTTPServer callback interfaces
from tornado.concurrent import Future
from tornado import gen
from somewhere import parse_headers
class HTTPReader(object):
def __init__(self, stream):
self.stream = stream
self.header_future = Future()
self.chunk_future = None
self.read_ready = Future()
@bdarnell
bdarnell / run.py
Created February 25, 2015 03:14
Python yield_loop macro
import macropy.activate
import test
@bdarnell
bdarnell / cockroach-cla.md
Created July 21, 2015 17:22
Cockroach Labs CLA

Cockroach Labs, Inc.

Contributor License Agreement

Thank you for your interest in the open source project(s) managed by Cockroach Labs, Inc. (“Cockroach Labs”). In order to clarify the intellectual property license granted with Contributions from any person or entity, Cockroach Labs must have a Contributor License Agreement (“CLA”) on file that has been signed by each contributor, indicating agreement to the license terms below. This license is for your protection as a contributor as well as the protection of Cockroach Labs and its other contributors and users; it does not change your rights to use your own Contributions for any other purpose.

By clicking “Accept” on this page You accept and agree to these terms and conditions for Your present and future Contributions submitted to Cockroach Labs. In return, Cockroach Labs shall consider Your Contributions for addition to the official Cockroach Labs open source project(s) for which they were submitted. Except for the license granted herein to Cockroach

@bdarnell
bdarnell / gist:614241
Created October 6, 2010 22:31
dowser patch
diff --git a/tools/third_party/dowser/__init__.py b/tools/third_party/dowser/__init__.py
index fa562b1..d716a2a 100644
--- a/tools/third_party/dowser/__init__.py
+++ b/tools/third_party/dowser/__init__.py
@@ -54,6 +54,7 @@ class Root:
if cherrypy.__version__ >= '3.1':
cherrypy.engine.subscribe('exit', self.stop)
self.runthread = threading.Thread(target=self.start)
+ self.runthread.daemon = True
self.runthread.start()
@bdarnell
bdarnell / gist:736778
Created December 10, 2010 20:43
benchmark: with vs try
#!/usr/bin/env python
# simple benchmark comparing with and try statements
import contextlib
import timeit
def work_pass():
pass
@bdarnell
bdarnell / result_collector.py
Created December 14, 2010 20:27
result_collector.py
import functools
import logging
import sys
class ResultCollector(object):
'''Like a BarrierCallback, but saves results passed to the callback.
>>> rc = ResultCollector()
>>> cb_foo = rc.get_callback('foo')
>>> cb_bar = rc.get_callback('bar')
@bdarnell
bdarnell / demo.py
Created July 25, 2016 00:27
Tornado monitoring wrappers (proof of concept)
from tornado import gen
from tornado.httpclient import AsyncHTTPClient
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.options import define, options, parse_command_line
from tornado.web import RequestHandler, Application
define('port', default=8888)
define('trace', default=False)
@bdarnell
bdarnell / ssltest.py
Created May 24, 2014 16:26
Test case for interrupted SSL handshake
import contextlib
import os.path
import socket
import ssl
import unittest
from tornado.iostream import SSLIOStream
from tornado import netutil, testing
from tornado.testing import AsyncTestCase, bind_unused_port
package main
import (
"context"
"fmt"
"math/rand"
"net"
"sync"
"time"
)
### Keybase proof
I hereby claim:
* I am bdarnell on github.
* I am bdarnell (https://keybase.io/bdarnell) on keybase.
* I have a public key ASCyOPV6SzNXv7CtLZJ_z_8Z0CUqe5Y1TX4iqDF03kYlPQo
To claim this, I am signing this object: