def inmem_queue(): with connection() as conn: e = Worker(queues="pytest", connection=conn) c = Queue(queue="pytest", connection=conn) c.e = e c.storage.clear(force=True) yield c e.shutdown()
def inmem_queue(): with tempfile.NamedTemporaryFile() as f: connection = create_engine( "sqlite:///{path}".format(path=f.name), connect_args={"check_same_thread": False}, poolclass=NullPool, ) e = Worker(queues="pytest", connection=connection) c = Queue(queue="pytest", connection=connection) c.e = e yield c e.shutdown()
def inmem_queue(): fd, filepath = tempfile.mkstemp() connection = create_engine( "sqlite:///{path}".format(path=filepath), connect_args={"check_same_thread": False}, poolclass=NullPool, ) e = Worker(queues="pytest", connection=connection) c = Queue(queue="pytest", connection=connection) c.e = e yield c e.shutdown() os.close(fd) try: os.remove(filepath) except OSError: pass