Repository: litestar-org/litestar

Issue:
Bug: Fix issues with py-redis >=4.5.0
### Description

We currently pin redis to version `4.4.4` because any version above that causes test failues. I was not able to determine the reason for this test failures, but this will cause issues for users who wish to use the newer versions of the library (version 5.0.0 is already out). 

Tasks:

1. unpin the redis version.
2. fix the issues causing the test failures.

### URL to code causing the issue

_No response_

### MCVE

_No response_

### Steps to reproduce

_No response_

### Screenshots

_No response_

### Logs

_No response_

### Litestar Version

v2.0.0

### Platform

- [X] Linux
- [X] Mac
- [ ] Windows
- [ ] Other (Please specify in the description above)

<!-- POLAR PLEDGE BADGE START -->
---

## Funding
* If you would like to see an issue prioritized, make a pledge towards it!
* We receive the pledge once the issue is completed & verified

<a href="https://polar.sh/litestar-org/litestar/issues/2208">
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://polar.sh/api/github/litestar-org/litestar/issues/2208/pledge.svg?darkmode=1">
  <img alt="Fund with Polar" src="https://polar.sh/api/github/litestar-org/litestar/issues/2208/pledge.svg">
</picture>
</a>
<!-- POLAR PLEDGE BADGE END -->

StaticFilesConfig and virtual directories
I'm trying to write a ``FileSystemProtocol`` to load files from the package data using [importlib_resources](https://importlib-resources.readthedocs.io/en/latest/using.html#). But because ``directories`` is defined as ``DirectoryPath``, pydantic checks if the given directories exist in the local filesystem. 

This is not generally true, especially in any kind of virtual filesystem (e.g. a zipped package). I think this condition should be relaxed to support virtual filesystems.

https://github.com/starlite-api/starlite/blob/9bb6dcd57c10a591377cf8e3a537e9292566d5b9/starlite/config/static_files.py#L32


Discussion:

I agree. Do you want to submit a PR?

Resolving patch:
diff --git a/litestar/channels/plugin.py b/litestar/channels/plugin.py
--- a/litestar/channels/plugin.py
+++ b/litestar/channels/plugin.py
@@ -333,8 +333,6 @@ async def _on_shutdown(self) -> None:
             ]
         )
 
-        await self._backend.on_shutdown()
-
         if self._sub_task:
             self._sub_task.cancel()
             with suppress(CancelledError):
@@ -345,6 +343,8 @@ async def _on_shutdown(self) -> None:
             with suppress(CancelledError):
                 await self._pub_task
 
+        await self._backend.on_shutdown()
+
     async def __aenter__(self) -> ChannelsPlugin:
         await self._on_startup()
         return self


Test patch:
diff --git a/tests/docker_service_fixtures.py b/tests/docker_service_fixtures.py
--- a/tests/docker_service_fixtures.py
+++ b/tests/docker_service_fixtures.py
@@ -6,6 +6,7 @@
 import subprocess
 import sys
 import timeit
+from pathlib import Path
 from typing import Any, Awaitable, Callable, Generator
 
 import asyncmy
@@ -53,7 +54,7 @@ def __init__(self, worker_id: str) -> None:
         self._base_command = [
             "docker",
             "compose",
-            "--file=tests/docker-compose.yml",
+            f"--file={Path(__file__).parent / 'docker-compose.yml'}",
             f"--project-name=litestar_pytest-{worker_id}",
         ]