Skip to content

Commit

Permalink
Use fixture to shut down ProcessPool
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Apr 30, 2022
1 parent f9dd6e9 commit c97e37f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
17 changes: 14 additions & 3 deletions lib/galaxy_test/base/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,22 @@ def handle_galaxy_config_kwds(cls, config):
config["celery_broker"] = CELERY_BROKER
config["celery_backend"] = CELERY_BACKEND

@pytest.fixture(autouse=True)
@pytest.fixture(autouse=True, scope="session")
def _request_celery_app(self, celery_session_app, celery_config):
self._celery_app = celery_session_app
try:
self._celery_app = celery_session_app
yield
finally:
if os.environ.get("GALAXY_TEST_EXTERNAL") is None:
try:
from galaxy.celery import celery_app
except ImportError:
return

celery_app.fork_pool.stop()
celery_app.fork_pool.join(timeout=5)

@pytest.fixture(autouse=True)
@pytest.fixture(autouse=True, scope="session")
def _request_celery_worker(self, celery_session_worker, celery_config):
self._celery_worker = celery_session_worker

Expand Down
10 changes: 1 addition & 9 deletions lib/galaxy_test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@

@pytest.fixture(scope="session", autouse=True)
def celery_includes():
try:
yield ["galaxy.celery.tasks"]
finally:
from galaxy.celery import celery_app

fork_pool = getattr(celery_app, "fork_pool", None)
if fork_pool:
fork_pool.stop()
fork_pool.join(timeout=5)
yield ["galaxy.celery.tasks"]


def get_timings(test_uuid):
Expand Down

0 comments on commit c97e37f

Please sign in to comment.