Most of programs will not accept an email using just @localhost as domain.
So, edit /etc/hosts file to make the domain localhost.com point to your machine, including this content to the file:
127.0.0.1 localhost.com
| def get_count(q): | |
| count_q = q.statement.with_only_columns([func.count()]).order_by(None) | |
| count = q.session.execute(count_q).scalar() | |
| return count | |
| q = session.query(TestModel).filter(...).order_by(...) | |
| # Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ... | |
| print q.count() |
| import multiprocessing | |
| # split a list into evenly sized chunks | |
| def chunks(l, n): | |
| return [l[i:i+n] for i in range(0, len(l), n)] | |
| def do_job(job_id, data_slice): | |
| for item in data_slice: | |
| print "job", job_id, item |
Most of programs will not accept an email using just @localhost as domain.
So, edit /etc/hosts file to make the domain localhost.com point to your machine, including this content to the file:
127.0.0.1 localhost.com
| from sqlalchemy import create_engine | |
| from sqlalchemy.ext.declarative import declarative_base | |
| engine = create_engine("postgresql://user:@host/schema") | |
| Base = declarative_base() | |
| Base.metadata.reflect(engine) |
| from multiprocessing import Pool | |
| from functools import partial | |
| def _pickle_method(method): | |
| func_name = method.im_func.__name__ | |
| obj = method.im_self | |
| cls = method.im_class | |
| if func_name.startswith('__') and not func_name.endswith('__'): #deal with mangled names | |
| cls_name = cls.__name__.lstrip('_') | |
| func_name = '_' + cls_name + func_name |