Skip to content

Commit

Permalink
chg: Drop python 3.8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Nov 5, 2024
1 parent 6e94069 commit 73e1bbd
Show file tree
Hide file tree
Showing 10 changed files with 267 additions and 619 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ jobs:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
name: Python ${{ matrix.python-version }} sample

steps:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ jobs:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
name: Python ${{ matrix.python-version }}

steps:
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.19.0
hooks:
- id: pyupgrade
args: [--py38-plus]
args: [--py39-plus]
11 changes: 3 additions & 8 deletions bin/capture_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
import logging
import logging.config
import signal
import sys

from asyncio import Task
from datetime import datetime, timedelta
from typing import Optional, Set


from lacus.default import AbstractManager, get_config
Expand All @@ -21,10 +19,10 @@

class CaptureManager(AbstractManager):

def __init__(self, loglevel: Optional[int]=None) -> None:
def __init__(self, loglevel: int | None=None) -> None:
super().__init__(loglevel)
self.script_name = 'capture_manager'
self.captures: Set[Task] = set() # type: ignore[type-arg]
self.captures: set[Task] = set() # type: ignore[type-arg]
self.lacus = Lacus()

async def clear_dead_captures(self) -> None:
Expand All @@ -37,10 +35,7 @@ async def clear_dead_captures(self) -> None:
elif start_time < oldest_start_time:
self.logger.warning(f'{expected_uuid} has been running for too long. Started at {start_time}.')
capture = ongoing[expected_uuid]
if sys.version_info >= (3, 9):
capture.cancel(f'Capture as been running for more than {max_capture_time}s.')
else:
capture.cancel()
capture.cancel(f'Capture as been running for more than {max_capture_time}s.')
try:
await capture
except asyncio.CancelledError:
Expand Down
9 changes: 5 additions & 4 deletions bin/run_backend.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env python3

from __future__ import annotations

import argparse
import os
import time
from pathlib import Path
from subprocess import Popen
from typing import Optional, Dict

from redis import Redis
from redis.exceptions import ConnectionError
Expand All @@ -24,14 +25,14 @@ def check_running(name: str) -> bool:
return False


def launch_cache(storage_directory: Optional[Path]=None) -> None:
def launch_cache(storage_directory: Path | None=None) -> None:
if not storage_directory:
storage_directory = get_homedir()
if not check_running('cache'):
Popen(["./run_redis.sh"], cwd=(storage_directory / 'cache'))


def shutdown_cache(storage_directory: Optional[Path]=None) -> None:
def shutdown_cache(storage_directory: Path | None=None) -> None:
if not storage_directory:
storage_directory = get_homedir()
r = Redis(unix_socket_path=get_socket_path('cache'))
Expand All @@ -44,7 +45,7 @@ def launch_all() -> None:


def check_all(stop: bool=False) -> None:
backends: Dict[str, bool] = {'cache': False}
backends: dict[str, bool] = {'cache': False}
while True:
for db_name in backends.keys():
try:
Expand Down
10 changes: 6 additions & 4 deletions lacus/lacus.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env python3

from __future__ import annotations

import copy
import logging

from datetime import datetime
from typing import Dict, Any
from typing import Any

from redis import Redis, ConnectionPool
from redis.connection import UnixDomainSocketConnection
Expand Down Expand Up @@ -57,7 +59,7 @@ def redis_decode(self) -> Redis: # type: ignore[type-arg]
def check_redis_up(self) -> bool:
return self.redis.ping()

def redis_status(self) -> Dict[str, Any]:
def redis_status(self) -> dict[str, Any]:
redis_info = self.redis.info()
return {'total_keys': redis_info['db0']['keys'] if 'db0' in redis_info else 0,
'current_memory_use': redis_info['used_memory_rss_human'],
Expand All @@ -73,8 +75,8 @@ def is_busy(self) -> bool:
enqueued_captures = len(self.monitoring.get_enqueued_captures())
return number_ongoing_captures + enqueued_captures >= max_concurrent_captures

def status(self) -> Dict[str, Any]:
to_return: Dict[str, Any] = {}
def status(self) -> dict[str, Any]:
to_return: dict[str, Any] = {}
to_return['max_concurrent_captures'] = get_config('generic', 'concurrent_captures')
to_return['max_capture_time'] = get_config('generic', 'max_capture_time')
ongoing_captures = self.monitoring.get_ongoing_captures()
Expand Down
Loading

0 comments on commit 73e1bbd

Please sign in to comment.