| 49 | return value |
| 50 | |
| 51 | def set_and_release( |
| 52 | self, host: str, port: int, supports_http2: bool | None |
| 53 | ) -> None: |
| 54 | key = (host, port) |
| 55 | key_lock = self._cache_locks[key] |
| 56 | with key_lock: # Uses an RLock, so can be locked again from same thread. |
| 57 | if supports_http2 is None and self._cache_values[key] is not None: |
| 58 | raise ValueError( |
| 59 | "Cannot reset HTTP/2 support for origin after value has been set." |
| 60 | ) # Defensive: not expected in normal usage |
| 61 | |
| 62 | self._cache_values[key] = supports_http2 |
| 63 | key_lock.release() |
| 64 | |
| 65 | def _values(self) -> dict[tuple[str, int], bool | None]: |
| 66 | """This function is for testing purposes only. Gets the current state of the probe cache""" |