26 lines
754 B
Python
26 lines
754 B
Python
|
|
import asyncio
|
||
|
|
|
||
|
|
from tamq.service import Service
|
||
|
|
from tamq.store import Store
|
||
|
|
|
||
|
|
|
||
|
|
def test_service_shutdown_removes_socket(tmp_path, monkeypatch):
|
||
|
|
monkeypatch.setenv("TAMQ_PIDFILE", str(tmp_path / "tamq.pid"))
|
||
|
|
async def run():
|
||
|
|
socket = tmp_path / "tamq.sock"
|
||
|
|
service = Service(socket, Store(tmp_path / "queue.sqlite3"))
|
||
|
|
task = asyncio.create_task(service.run())
|
||
|
|
for _ in range(20):
|
||
|
|
if socket.exists():
|
||
|
|
break
|
||
|
|
await asyncio.sleep(0.01)
|
||
|
|
assert socket.exists()
|
||
|
|
service.server.close()
|
||
|
|
await service.server.wait_closed()
|
||
|
|
task.cancel()
|
||
|
|
try:
|
||
|
|
await task
|
||
|
|
except asyncio.CancelledError:
|
||
|
|
pass
|
||
|
|
asyncio.run(run())
|