Skip to content

Instantly share code, notes, and snippets.

View GrahamDumpleton's full-sized avatar
😎

Graham Dumpleton GrahamDumpleton

😎
View GitHub Profile
@GrahamDumpleton
GrahamDumpleton / gist:4133897
Created November 23, 2012 03:36
uWSGI crash when using -p 2 option.
$ uwsgi --ini uwsgi.ini -p 2
[uWSGI] getting INI configuration from uwsgi.ini
*** Starting uWSGI 1.4.1 (64bit) on [Fri Nov 23 14:35:44 2012] ***
compiled with version: 4.2.1 (Apple Inc. build 5666) (dot 3) on 22 November 2012 16:19:23
os: Darwin-10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386
nodename: Grumpys-MacBook-Pro-15.local
machine: i386
clock source: unix
detected number of CPU cores: 4
current working directory: /Library/WebServer/Sites/hello-1/htdocs
@GrahamDumpleton
GrahamDumpleton / gist:4133912
Created November 23, 2012 03:41
uWSGI crash when supplying float to --reload-mercy.
$ uwsgi --ini uwsgi.ini -M -p 2 --reload-mercy 3.0
[uWSGI] getting INI configuration from uwsgi.ini
*** Starting uWSGI 1.4.1 (64bit) on [Fri Nov 23 14:40:25 2012] ***
compiled with version: 4.2.1 (Apple Inc. build 5666) (dot 3) on 22 November 2012 16:19:23
os: Darwin-10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386
nodename: Grumpys-MacBook-Pro-15.local
machine: i386
clock source: unix
detected number of CPU cores: 4
current working directory: /Library/WebServer/Sites/hello-1/htdocs
@GrahamDumpleton
GrahamDumpleton / gist:4133917
Created November 23, 2012 03:44
uWSGI error on shutting down with master, multiple processes and reload mercy.
$ uwsgi --ini uwsgi.ini -M -p 2 --reload-mercy 3
[uWSGI] getting INI configuration from uwsgi.ini
*** Starting uWSGI 1.4.1 (64bit) on [Fri Nov 23 14:43:05 2012] ***
compiled with version: 4.2.1 (Apple Inc. build 5666) (dot 3) on 22 November 2012 16:19:23
os: Darwin-10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386
nodename: Grumpys-MacBook-Pro-15.local
machine: i386
clock source: unix
detected number of CPU cores: 4
current working directory: /Library/WebServer/Sites/hello-1/htdocs
@GrahamDumpleton
GrahamDumpleton / gist:4341587
Created December 19, 2012 23:22
Manual method for optionally initialising agent based on environment variables.
# Add this at start of WSGI file before any imports, but if necessary after setting
# sys.path so that 'newrelic' package can be found.
import os
license_key = os.environ.get('NEW_RELIC_LICENSE_KEY', None)
config_file = os.environ.get('NEW_RELIC_CONFIG_FILE', None)
environment = os.environ.get('NEW_RELIC_ENVIRONMENT', None)
@GrahamDumpleton
GrahamDumpleton / gist:4590267
Created January 21, 2013 22:51
Gunicorn crashing on closing file descriptors.
Traceback (most recent call last):
File "test-env/bin/gunicorn", line 8, in <module>
load_entry_point('gunicorn==0.16.1', 'console_scripts', 'gunicorn')()
File "/Users/graham/Work/python_agent-1.10.X/test-env/lib/python2.6/site-packages/gunicorn/app/wsgiapp.py", line 32, in run
WSGIApplication("%prog [OPTIONS] APP_MODULE").run()
File "/Users/graham/Work/python_agent-1.10.X/test-env/lib/python2.6/site-packages/gunicorn/app/base.py", line 127, in run
Arbiter(self).run()
File "/Users/graham/Work/python_agent-1.10.X/test-env/lib/python2.6/site-packages/gunicorn/arbiter.py", line 162, in run
self.start()
File "/Users/graham/Work/python_agent-1.10.X/test-env/lib/python2.6/site-packages/gunicorn/arbiter.py", line 122, in start
# Put this on module path in file newrelic_django_nap.py.
#
# In agent configuration file add:
#
# [import-hook:nap.publisher]
# enabled = true
# execute = newrelic_django_nap:instrument_django_nap_publisher
from newrelic.agent import (current_transaction, set_transaction_name,
FunctionTrace, callable_name, wrap_function_wrapper)
@GrahamDumpleton
GrahamDumpleton / gist:6418300
Created September 2, 2013 23:52
Example of a module proxy which selectively overrides behaviour of specific functions.
from __future__ import print_function
import wrapt
import time
import sys
class TimeModuleProxy(wrapt.ObjectProxy):
def __init__(self, module=time):
super(TimeModuleProxy, self).__init__(module)
@GrahamDumpleton
GrahamDumpleton / gist:6694421
Last active December 23, 2015 21:09
PASS/FAIL matrix for various requests module versions and proxy SSL request via Squid.

Squid configuration:

http_port 3128
https_port 3129 cert=/usr/local/opt/squid/etc/ssl/squid.crt key=/usr/local/opt/squid/etc/ssl/squid.key

Test names:

The 'http_port' annotation indicates whether Squid HTTP port was used.

The 'https_port' annotation indicates whether Squid HTTPS port was used.

@GrahamDumpleton
GrahamDumpleton / gist:7348692
Created November 7, 2013 03:51
Why list(six.iteritems(d)) is bad.
>>> d = { "a": "b" }
>>> i = iter(d.iteritems())
>>> i
<dictionary-itemiterator object at 0x1072d8cb0>
>>> d["c"] = "d"
>>> list(i)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: dictionary changed size during iteration
@GrahamDumpleton
GrahamDumpleton / gist:7671860
Created November 27, 2013 07:22
Strange warning logged by pypy.
Exception AssertionError: AssertionError() in interrupting generator of <generator object __iter__ at 0x0000000107c489f8> ignored