Skip to content

Instantly share code, notes, and snippets.

View schmohlio's full-sized avatar

Matthew Schmohl schmohlio

View GitHub Profile
@schmohlio
schmohlio / test3.py
Created May 25, 2014 02:17
testing EmbeddedFunctionHandler part 3
dirty_ls = list(l)
dirty_ls[600], dirty_ls[20000] = ("kittens","cats")
res = map(add_one2,dirty_ls)
# ***Repl Closed***
@schmohlio
schmohlio / test2.py
Created May 25, 2014 01:53
test EmbeddedFunctionHandler part 2
EmbeddedFunctionHandler.init_log('file.log', logging.DEBUG)
MAX_ERRORS = 2
@EmbeddedFunctionHandler("catch errors adding 1", MAX_ERRORS)
def add_one2(x):
return x+1
%timeit map(add_one2,l)
# 1 loops, best of 3: 1.13 s per loop
@schmohlio
schmohlio / test1.py
Created May 25, 2014 01:14
test EmbeddedFucntionHandler 1
import numpy as np
from multiprocessing import Pool
def add_one(x):
return x+1
p = Pool(4)
l = np.arange(0,1000000)
%timeit p.map(add_one, l)
@schmohlio
schmohlio / EmbeddedFunctionHandler.py
Created May 24, 2014 01:52
An error handler for functions that are embedded within parallelized functions
"""
EmbeddedFunctionHandler.py
A class that decorates functions that are embedded/called within
other map|reduce functions. Provides error logging
to log. Type of error and function *args are logged. Useful for Python's
dynamic typing
"""