def merge_datafile(line): """ Add all the requests/responses from another data file to the current one """ def set_text_factory(conn): conn.text_factory = str line = line.strip() other_dbpool = adbapi.ConnectionPool("sqlite3", line, check_same_thread=False, cp_openfun=set_text_factory, cp_max=1) try: count = 0 other_cache = RequestCache(cust_dbpool=other_dbpool) yield other_cache.load_ids() for req_d in other_cache.req_it(): count += 1 req = yield req_d r = req.copy() yield r.async_deep_save() print 'Added %d requests' % count finally: other_dbpool.close()