forked from platypush/platypush
Using a single constant for DEFAULT_REDIS_QUEUE.
Also, catch `AttributeError` on `self._proc.terminate` in the `HttpBackend`, since the process may already have been terminated and set to null by another worker process.
This commit is contained in:
parent
4062ddbcf0
commit
827b564006
3 changed files with 10 additions and 9 deletions
|
@ -25,9 +25,6 @@ log = logging.getLogger('platypush')
|
||||||
class Application:
|
class Application:
|
||||||
"""Main class for the Platypush application."""
|
"""Main class for the Platypush application."""
|
||||||
|
|
||||||
# Default bus queue name
|
|
||||||
_default_redis_queue = 'platypush/bus'
|
|
||||||
|
|
||||||
# Default Redis port
|
# Default Redis port
|
||||||
_default_redis_port = 6379
|
_default_redis_port = 6379
|
||||||
|
|
||||||
|
@ -90,7 +87,7 @@ class Application:
|
||||||
f.write(str(os.getpid()))
|
f.write(str(os.getpid()))
|
||||||
|
|
||||||
self.bus: Optional[Bus] = None
|
self.bus: Optional[Bus] = None
|
||||||
self.redis_queue = redis_queue or self._default_redis_queue
|
self.redis_queue = redis_queue or RedisBus.DEFAULT_REDIS_QUEUE
|
||||||
self.config_file = config_file
|
self.config_file = config_file
|
||||||
self._verbose = verbose
|
self._verbose = verbose
|
||||||
self._logsdir = (
|
self._logsdir = (
|
||||||
|
|
|
@ -269,8 +269,12 @@ class HttpBackend(Backend):
|
||||||
self._workers.pop(i)
|
self._workers.pop(i)
|
||||||
|
|
||||||
if self._server_proc:
|
if self._server_proc:
|
||||||
|
try:
|
||||||
self._server_proc.terminate()
|
self._server_proc.terminate()
|
||||||
self._server_proc.join(timeout=5)
|
self._server_proc.join(timeout=5)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
self._server_proc = None
|
self._server_proc = None
|
||||||
|
|
||||||
if self._server_proc and self._server_proc.is_alive():
|
if self._server_proc and self._server_proc.is_alive():
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
from typing import Optional
|
from typing import Final, Optional
|
||||||
|
|
||||||
from platypush.bus import Bus
|
from platypush.bus import Bus
|
||||||
from platypush.message import Message
|
from platypush.message import Message
|
||||||
|
@ -13,7 +13,7 @@ class RedisBus(Bus):
|
||||||
Overrides the in-process in-memory local bus with a Redis bus
|
Overrides the in-process in-memory local bus with a Redis bus
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_DEFAULT_REDIS_QUEUE = 'platypush/bus'
|
DEFAULT_REDIS_QUEUE: Final[str] = 'platypush/bus'
|
||||||
|
|
||||||
def __init__(self, *args, on_message=None, redis_queue=None, **kwargs):
|
def __init__(self, *args, on_message=None, redis_queue=None, **kwargs):
|
||||||
from platypush.utils import get_redis
|
from platypush.utils import get_redis
|
||||||
|
@ -21,7 +21,7 @@ class RedisBus(Bus):
|
||||||
super().__init__(on_message=on_message)
|
super().__init__(on_message=on_message)
|
||||||
self.redis = get_redis(*args, **kwargs)
|
self.redis = get_redis(*args, **kwargs)
|
||||||
self.redis_args = kwargs
|
self.redis_args = kwargs
|
||||||
self.redis_queue = redis_queue or self._DEFAULT_REDIS_QUEUE
|
self.redis_queue = redis_queue or self.DEFAULT_REDIS_QUEUE
|
||||||
self.on_message = on_message
|
self.on_message = on_message
|
||||||
self.thread_id = threading.get_ident()
|
self.thread_id = threading.get_ident()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue