diff --git a/.github/workflows/build_beta.yaml b/.github/workflows/build_beta.yaml index 1cf5aca..10a18ab 100644 --- a/.github/workflows/build_beta.yaml +++ b/.github/workflows/build_beta.yaml @@ -9,12 +9,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - name: Ensure python 3.11 - uses: actions/setup-python@v4 + - name: Ensure python 3.12 + uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: '3.12' - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install dependencies run: pip install -r requirements.txt; pip install pylint==${{ secrets.PYLINT_VERSION }} - name: Run lint @@ -27,14 +27,14 @@ jobs: - name: Verify tag run: echo ${{ steps.docker_tag.outputs.tag }} - name: Login to GCR - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: us-docker.pkg.dev username: _json_key password: ${{ secrets.GCR_JSON_KEY }} - name: Build and push id: docker_build - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: push: true pull: true @@ -44,7 +44,7 @@ jobs: tags: us-docker.pkg.dev/plaidcloud-build/us-plaidcloud/redistomp:latest,us-docker.pkg.dev/plaidcloud-build/us-plaidcloud/redistomp:${{ steps.docker_tag.outputs.tag }} - name: Checkout GitOps Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: PlaidCloud/plaid-tenant-infrastructure ref: beta diff --git a/.github/workflows/build_io.yaml b/.github/workflows/build_io.yaml index 9588659..cd603ac 100644 --- a/.github/workflows/build_io.yaml +++ b/.github/workflows/build_io.yaml @@ -9,12 +9,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - name: Ensure python 3.11 - uses: actions/setup-python@v4 + - name: Ensure python 3.12 + uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: '3.12' - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install dependencies run: pip install -r requirements.txt; pip install pylint==${{ secrets.PYLINT_VERSION }} - name: Run lint @@ -27,14 +27,14 @@ jobs: - name: Verify tag run: echo ${{ steps.docker_tag.outputs.tag }} - name: Login to GCR - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: us-docker.pkg.dev username: _json_key password: ${{ secrets.GCR_JSON_KEY }} - name: Build and push id: docker_build - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: push: true pull: true @@ -44,7 +44,7 @@ jobs: tags: us-docker.pkg.dev/plaidcloud-build/us-plaidcloud/redistomp:latest,us-docker.pkg.dev/plaidcloud-build/us-plaidcloud/redistomp:${{ steps.docker_tag.outputs.tag }} - name: Checkout GitOps Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: PlaidCloud/plaid-tenant-infrastructure ref: master diff --git a/.github/workflows/pr_lint.yaml b/.github/workflows/pr_lint.yaml index d292f5c..b9a5639 100644 --- a/.github/workflows/pr_lint.yaml +++ b/.github/workflows/pr_lint.yaml @@ -1,24 +1,24 @@ -name: Lint PlaidCloud RPC Service +name: Lint RediStomp Service on: pull_request: branches: - - master + - main jobs: reviewdog: name: Lint RediStomp w ReviewDog runs-on: ubuntu-latest timeout-minutes: 5 steps: - - name: Ensure python 3.11 - uses: actions/setup-python@v4 + - name: Ensure python 3.12 + uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: '3.12' - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Acquire list of changed python files id: all-python-files continue-on-error: true - uses: tj-actions/changed-files@v37 + uses: tj-actions/changed-files@v45 with: files: | **/*.py @@ -45,4 +45,4 @@ jobs: env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - pylint -s n -f text -E plaid 2>&1 | reviewdog -efm="%f:%l:%c: %m" -name="PyLint Errors" -reporter=github-check -filter-mode=nofilter -fail-on-error + pylint -s n -f text -E redis_stomp 2>&1 | reviewdog -efm="%f:%l:%c: %m" -name="PyLint Errors" -reporter=github-check -filter-mode=nofilter -fail-on-error diff --git a/Dockerfile b/Dockerfile index 5078acf..8c465af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11-slim +FROM python:3.12-slim ARG RUN_AS_USER ARG REDIS_URL diff --git a/redis_stomp/pubsub/topic.py b/redis_stomp/pubsub/topic.py index 367e1a4..ee3e0c2 100644 --- a/redis_stomp/pubsub/topic.py +++ b/redis_stomp/pubsub/topic.py @@ -94,12 +94,13 @@ async def unsubscribe(self, connection: StompConnection, destination: str = None if not redis_destination: return await super().unsubscribe(connection, redis_destination, id) - if glob.has_magic(redis_destination): - LOGGER.debug(f'PUNSUBSCRIBE: {redis_destination}') - await asyncio.to_thread(self._redis.punsubscribe, redis_destination) - else: - LOGGER.debug(f'UNSUBSCRIBE: {redis_destination}') - await asyncio.to_thread(self._redis.unsubscribe, redis_destination) + if await self._subscriptions.subscriber_count(redis_destination) == 0: + if glob.has_magic(redis_destination): + LOGGER.debug(f'PUNSUBSCRIBE: {redis_destination}') + await asyncio.to_thread(self._redis.punsubscribe, redis_destination) + else: + LOGGER.debug(f'UNSUBSCRIBE: {redis_destination}') + await asyncio.to_thread(self._redis.unsubscribe, redis_destination) async def next_message(self): # ToDo: This could be done by registering a callback on subscribe which might be more favorable, I dunno diff --git a/requirements.txt b/requirements.txt index 1091f1c..e239e15 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -anyio==4.0.0 +anyio==4.4.0 coilmq@git+https://github.com/rad-pat/coilmq.git@asyncio#egg=coilmq -redis==5.0.1 -starlette==0.31.1 -uvicorn==0.23.2 -uvloop==0.19.0 -websockets==12.0 +redis==5.0.8 +starlette==0.38.5 +uvicorn==0.30.6 +uvloop==0.20.0 +websockets==13.0.1