Skip to content

Commit

Permalink
Merge pull request #64 from openstreetmap-polska/dev
Browse files Browse the repository at this point in the history
Release to main
  • Loading branch information
Zaczero authored Feb 26, 2024
2 parents 0205083 + f04ebe2 commit 11edde9
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 196 deletions.
4 changes: 1 addition & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
from motor.motor_asyncio import AsyncIOMotorClient
from pymongo import IndexModel
from pyproj import Transformer
from sentry_sdk.integrations.asyncio import AsyncioIntegration
from sentry_sdk.integrations.pymongo import PyMongoIntegration

NAME = 'openaedmap-backend'
VERSION = '2.8.0'
VERSION = '2.8.1'
CREATED_BY = f'{NAME} {VERSION}'
WEBSITE = 'https://openaedmap.org'

Expand All @@ -29,7 +28,6 @@
trace_propagation_targets=None,
profiles_sample_rate=0.2,
integrations=[
AsyncioIntegration(),
PyMongoIntegration(),
],
)
Expand Down
2 changes: 1 addition & 1 deletion envs/compose/dev.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
LISTEN=127.0.0.1:49223
WORKERS=4
WORKERS=3
2 changes: 1 addition & 1 deletion envs/compose/main.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
LISTEN=127.0.0.1:49222
WORKERS=12
WORKERS=8
300 changes: 127 additions & 173 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ lxml = "^5.1.0"
mapbox-vector-tile = "^2.0.1"
motor = "^3.3.2"
msgspec = "<1"
networkx = "^3.2.1"
numpy = "^1.26.3"
pillow = "^10.2.0"
psutil = "^5.9.7"
pyinstrument = "^4.6.1"
pyproj = "^3.6.1"
python = "^3.12"
Expand Down
23 changes: 9 additions & 14 deletions states/worker_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
from enum import Enum

import anyio
import psutil
from anyio import Path

from config import NAME
from utils import retry_exponential

_PID_PATH = anyio.Path(f'/tmp/{NAME}-worker.pid')
_STATE_PATH = anyio.Path(f'/tmp/{NAME}-worker.state')
_LOCK_PATH = anyio.Path(f'/tmp/{NAME}-worker.lock')
_PID_PATH = Path(f'/tmp/{NAME}-worker.pid')
_STATE_PATH = Path(f'/tmp/{NAME}-worker.state')
_LOCK_PATH = Path(f'/tmp/{NAME}-worker.lock')


class WorkerStateEnum(str, Enum):
Expand All @@ -35,17 +35,12 @@ async def ainit(self) -> None:
self.is_primary = False

while True:
if not await _PID_PATH.is_file() or not await _STATE_PATH.is_file():
await anyio.sleep(0.1)
continue
if await _PID_PATH.is_file() and await _STATE_PATH.is_file():
pid = await _PID_PATH.read_text()
if pid and await Path(f'/proc/{pid}').is_dir():
break

pid = await _PID_PATH.read_text()

if not pid or not psutil.pid_exists(int(pid)):
await anyio.sleep(0.1)
continue

break
await anyio.sleep(0.1)

async def set_state(self, state: WorkerStateEnum) -> None:
assert self.is_primary
Expand Down
3 changes: 1 addition & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,4 @@ def get_wikimedia_commons_url(path: str) -> str:


def simple_point_mapping(point: Point) -> dict:
x, y = get_coordinates(point)[0].tolist()
return {'type': 'Point', 'coordinates': (x, y)}
return {'type': 'Point', 'coordinates': get_coordinates(point)[0].tolist()}

0 comments on commit 11edde9

Please sign in to comment.