Skip to content

Instantly share code, notes, and snippets.


View GitHub Profile
Sovetnikov /
Created Jun 27, 2019
Dramatiq eager broker for unittest
from dramatiq import Worker
from dramatiq.brokers.stub import StubBroker
from dramatiq.worker import _WorkerThread, _ConsumerThread
class EagerBroker(StubBroker):
def __init__(self, *args, **kwargs):
super(EagerBroker, self).__init__(*args, **kwargs)
self.worker = Worker(self, worker_timeout=100)
import random
import re
import socket
import ssl
from urllib.parse import urlparse
from urllib.request import urlopen
import socks
from shared.enum import StrEnum
Sovetnikov /
Created Jan 14, 2018
SocksiPy рабочий для Python 3.4
"""SocksiPy - Python SOCKS module.
Version 1.00
Copyright 2006 Dan-Haim. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
import os
import subprocess
import unittest
from datetime import timedelta
from random import SystemRandom
from celery import Celery
from kombu import Exchange
from kombu import Queue
Sovetnikov /
Created Feb 13, 2017
How to run celery cam to save memory by not loading all modules of your app
import os
import time
from copy import copy
from import evcam
from qiwichain import settings as novtest_settings
from qiwichain.celery import app
DATABASES = copy(novtest_settings.DATABASES)
Sovetnikov /
Last active Jul 30, 2019
django-fsm-log admin model inline for Django 1.7.7
from django.contrib.admin import TabularInline
from django.contrib.admin.utils import flatten_fieldsets
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.forms import BaseInlineFormSet, BaseModelFormSet
from django_fsm_log.models import StateLog
# Making possible to show django inline model admin without actual foreign key to parent model
# Works by making new model that has required FK (just to pass startup checks) and overriding actual queryset generated in FormSet
# For Django 1.7.7
import logging
import os
ABSOLUTE_PATH = lambda x: os.path.abspath(os.path.join(os.path.abspath(os.path.dirname(__file__)), x))
# For Django 1.7.7 sqlite and spatialite
# Uses monkeypatch
# Runs tests as:
# 1. Create initial db and apply all migrations if it does not exists
You can’t perform that action at this time.