Skip to content

Instantly share code, notes, and snippets.

Nick Humrich nhumrich

Block or report user

Report or block nhumrich

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
nhumrich /
Created Aug 10, 2017
asyncpgsa benchmark against
import asyncio
import aiopg
import asyncpg
import asyncpgsa
import sqlalchemy as sa
pg_tables = sa.Table(
'pg_tables', sa.MetaData(),
nhumrich /
Last active Jun 13, 2017
metaclass wrapping vs __getattr__
import functools
import inspect
from timeit import timeit
class Bob:
__slots__ = ('a',)
def __init__(self):
self.a = 5
nhumrich /
Created Jan 27, 2017
get free o'reilly books
"""Script to download free O'Reilly ebooks."""
import asyncio
import os
import re
import sys
import aiohttp
filename_matcher = re.compile(r'*)/free/(.*).csp')
session = None
nhumrich /
Last active Sep 27, 2018
async vs threading cpu bound benchmark
import asyncio
from multiprocessing.pool import ThreadPool
from timeit import timeit
from functools import partial
pool = ThreadPool(processes=400)
loop = asyncio.get_event_loop()
def fib(x):
nhumrich /
Created Nov 3, 2016
async vs threading http benchmark
from timeit import timeit
import asyncio
import requests
from threading import Thread
import aiohttp
client = aiohttp.ClientSession()
nhumrich /
Last active Aug 19, 2018
async blog tornado example
import tornado.ioloop
from tornado.httpclient import AsyncHTTPClient
urls = ['', '', '']
def handle_response(response):
if response.error:
print("Error:", response.error)
url = response.request.url
data = response.body
nhumrich /
Last active Aug 19, 2018
async blog post gevent example
import gevent.monkey
from urllib.request import urlopen
urls = ['', '', '']
def print_head(url):
print('Starting {}'.format(url))
data = urlopen(url).read()
print('{}: {} bytes: {}'.format(url, len(data), data))
nhumrich / asyncio_drain.patch
Last active Sep 8, 2016
python asyncio drain feature patch
View asyncio_drain.patch
diff -r c2212d98ef13 Lib/asyncio/
--- a/Lib/asyncio/ Wed Sep 07 14:56:15 2016 -0700
+++ b/Lib/asyncio/ Wed Sep 07 21:56:33 2016 -0600
@@ -1,13 +1,13 @@
-__all__ = ['Queue', 'PriorityQueue', 'LifoQueue', 'QueueFull', 'QueueEmpty']
+__all__ = ['Queue', 'PriorityQueue', 'LifoQueue',
+ 'QueueFull', 'QueueEmpty', 'QueueClosed']
import dns.resolver
import os
from urllib import request
import json
import time
nhumrich / durggletest.yml
Last active Aug 15, 2016
yaml example of api test
View durggletest.yml
- add a durggle:
post: /api/durggles
name: bob
spot: white
eyes: purple
- fish
- chips
You can’t perform that action at this time.