Skip to content

Commit

Permalink
Merge pull request #188 from peopledoc/ele_pg-job-store
Browse files Browse the repository at this point in the history
Remove PostgresJobStore (compatibility layer)
  • Loading branch information
Éric Lemoine committed Apr 21, 2020
2 parents e31df23 + 14bba35 commit 9dd6c29
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 50 deletions.
3 changes: 1 addition & 2 deletions procrastinate/__init__.py
@@ -1,13 +1,12 @@
from procrastinate import metadata as _metadata_module
from procrastinate.aiopg_connector import PostgresConnector, PostgresJobStore
from procrastinate.aiopg_connector import PostgresConnector
from procrastinate.app import App
from procrastinate.retry import BaseRetryStrategy, RetryStrategy

__all__ = [
"App",
"BaseRetryStrategy",
"PostgresConnector",
"PostgresJobStore",
"RetryStrategy",
]

Expand Down
11 changes: 0 additions & 11 deletions procrastinate/aiopg_connector.py
@@ -1,6 +1,5 @@
import asyncio
import logging
import warnings
from typing import Any, Callable, Dict, Iterable, List, NoReturn, Optional

import aiopg
Expand Down Expand Up @@ -222,13 +221,3 @@ async def _loop_notify(
continue

event.set()


def PostgresJobStore(*args, **kwargs):
message = (
"Use procrastinate.PostgresConnector(...) "
"instead of procrastinate.PostgresJobStore(...), with the same arguments"
)
logger.warning(f"Deprecation Warning: {message}")
warnings.warn(DeprecationWarning(message))
return PostgresConnector(**kwargs)
22 changes: 2 additions & 20 deletions procrastinate/app.py
@@ -1,6 +1,5 @@
import functools
import logging
import warnings
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, Optional, Set

from procrastinate import builtin_tasks
Expand Down Expand Up @@ -35,20 +34,17 @@ def from_path(cls, dotted_path: str):
def __init__(
self,
*,
connector: Optional[connector_module.BaseConnector] = None,
connector: connector_module.BaseConnector,
import_paths: Optional[Iterable[str]] = None,
worker_timeout: float = WORKER_TIMEOUT,
# Just for backwards compatibility
job_store: Optional[connector_module.BaseConnector] = None,
):
"""
Parameters
----------
connector:
Instance of a subclass of :py:class:`BaseConnector`, typically
:py:class:`PostgresConnector`. It will be responsible for all
communications with the database.
Mandatory if job_store is not passed.
communications with the database. Mandatory.
import_paths:
List of python dotted paths of modules to import, to make sure
that the workers know about all possible tasks.
Expand All @@ -68,21 +64,7 @@ def __init__(
this parameter.
Raising this parameter can lower the rate of workers making queries to the
database for requesting jobs.
job_store:
**Deprecated**: Old name of ``connector``.
"""
# Compatibility
if job_store:
message = (
"Use App(connector=procrastinate.PostgresConnector(...)) "
"instead of App(job_store=procrastinate.PostgresJobStore())"
)
logger.warning(f"Deprecation Warning: {message}")
warnings.warn(DeprecationWarning(message))
connector = job_store
if not connector:
raise TypeError("App() missing 1 required argument: 'connector'")

self.connector = connector
self.tasks: Dict[str, "tasks.Task"] = {}
self.builtin_tasks: Dict[str, "tasks.Task"] = {}
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -41,7 +41,7 @@ test =
pytest-mock
pytest-cov
pytest-click
pytest-asyncio
pytest-asyncio!=0.11.0

lint =
black
Expand Down
8 changes: 0 additions & 8 deletions tests/unit/test_aiopg_connector.py
@@ -1,6 +1,5 @@
import pytest

import procrastinate
from procrastinate import aiopg_connector


Expand Down Expand Up @@ -29,10 +28,3 @@ def test_adapt_pool_args_maxsize():
)

assert args["maxsize"] == 2


def test_app_deprecation(caplog, mocker):
with pytest.deprecated_call():
procrastinate.PostgresJobStore()
assert caplog.records[0].levelname == "WARNING"
assert caplog.records[0].message.startswith("Deprecation Warning")
8 changes: 0 additions & 8 deletions tests/unit/test_app.py
Expand Up @@ -3,7 +3,6 @@
import pendulum
import pytest

from procrastinate import aiopg_connector
from procrastinate import app as app_module
from procrastinate import tasks

Expand All @@ -12,13 +11,6 @@ def task_func():
pass


def test_app_deprecation(caplog):
with pytest.deprecated_call():
app_module.App(job_store=aiopg_connector.PostgresConnector)
assert caplog.records[0].levelname == "WARNING"
assert caplog.records[0].message.startswith("Deprecation Warning")


def test_app_no_connector():
with pytest.raises(TypeError):
app_module.App()
Expand Down

0 comments on commit 9dd6c29

Please sign in to comment.