add finalizer to stop worker on terminate
This commit is contained in:
parent
408c2271a6
commit
2a6c13fc5c
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -79,7 +79,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Django Testing project
|
- name: Django Testing project
|
||||||
timeout-minutes: 6
|
timeout-minutes: 6
|
||||||
run: pytest
|
run: pytest --junitxml=junit/test-results-${{ matrix.python-version }}.xml
|
||||||
|
|
||||||
- name: Publish Test Results
|
- name: Publish Test Results
|
||||||
uses: EnricoMi/publish-unit-test-result-action@v2
|
uses: EnricoMi/publish-unit-test-result-action@v2
|
||||||
|
@ -2,6 +2,7 @@ import asyncio
|
|||||||
import logging
|
import logging
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import queue
|
import queue
|
||||||
|
import weakref
|
||||||
from asyncio import Task
|
from asyncio import Task
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
@ -49,6 +50,7 @@ class ConnectorManager:
|
|||||||
self._queue = multiprocessing.JoinableQueue(maxsize=settings.EXTERNAL_CONNECTORS_QUEUE_SIZE)
|
self._queue = multiprocessing.JoinableQueue(maxsize=settings.EXTERNAL_CONNECTORS_QUEUE_SIZE)
|
||||||
self._worker = multiprocessing.Process(target=self.worker, args=(0, self._queue,), daemon=True)
|
self._worker = multiprocessing.Process(target=self.worker, args=(0, self._queue,), daemon=True)
|
||||||
self._worker.start()
|
self._worker.start()
|
||||||
|
self._finalizer = weakref.finalize(self, self.stop)
|
||||||
|
|
||||||
# Called by post save & post delete signals
|
# Called by post save & post delete signals
|
||||||
def __call__(self, instance: Any, **kwargs) -> None:
|
def __call__(self, instance: Any, **kwargs) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user