# -*- coding: utf-8 -*-
"""只操作本程序创建的临时对象；全部数据为合成样本。"""
import os, sys, json, sqlite3, tempfile, pathlib, subprocess, time, socket, stat
from pathlib import Path
def emit(**kw):
    print(json.dumps(kw, ensure_ascii=False, sort_keys=True))
c=sqlite3.connect(':memory:'); c.execute('CREATE TABLE t(n)'); c.executemany('INSERT INTO t VALUES(?)',[(i,) for i in range(100)]); calls=[0]
def budget():
    calls[0]+=1
    return calls[0]>20
c.set_progress_handler(budget,100)
try: c.execute('SELECT sum(a.n*b.n*c.n) FROM t a,t b,t c').fetchone(); interrupted=False
except sqlite3.OperationalError as e: interrupted='interrupted' in str(e)
c.set_progress_handler(None,0); health=c.execute('SELECT 1').fetchone()[0]
assert interrupted and health==1; emit(interrupted=interrupted,callbacks=calls[0],connection_health=health)
