<s> from random import choice <EOL> from string import ascii_letters <EOL> import os <EOL> import shutil <EOL> import tempfile <EOL> from dogpile . cache import make_region <EOL> def mkfile ( request ) : <EOL> temp_dir = tempfile . mkdtemp ( ) <EOL> temp_file = os . path . join ( <EOL> temp_dir , '<STR_LIT>' . join ( choice ( ascii_letters ) for i in range ( <NUM_LIT:10> ) ) <EOL> ) <EOL> def fin ( ) : <EOL> shutil . rmtree ( temp_dir ) <EOL> request . addfinalizer ( fin ) <EOL> return temp_file <EOL> def mksqlite ( request ) : <EOL> from epo_ops . middlewares . throttle . storages import SQLite , sqlite <EOL> db = SQLite ( mkfile ( request ) ) <EOL> assert db . db_path != sqlite . DEFAULT_DB_PATH <EOL> return db <EOL> def mkthrottler ( request ) : <EOL> from epo_ops . middlewares import Throttler <EOL> return Throttler ( mksqlite ( request ) ) <EOL> def mkcache ( request ) : <EOL> from epo_ops . middlewares import Dogpile <EOL> from epo_ops . middlewares . cache . dogpile import dogpile <EOL> region = make_region ( ) . configure ( <EOL> '<STR_LIT>' , <EOL> expiration_time = dogpile . DEFAULT_TIMEOUT , <EOL> arguments = { '<STR_LIT:filename>' : mkfile ( request ) } <EOL> ) <EOL> return Dogpile ( region ) </s>
