mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-06 22:58:12 +08:00
#50 adds psutil as alternative os.getppid provider
This commit is contained in:
@@ -7,6 +7,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings
|
||||
|
||||
# external
|
||||
import os
|
||||
import redis
|
||||
|
||||
# optional
|
||||
@@ -143,3 +144,13 @@ def get_redis_client():
|
||||
|
||||
# redis client
|
||||
redis_client = get_redis_client()
|
||||
|
||||
|
||||
# get parent pid compatibility
|
||||
def get_ppid():
|
||||
if hasattr(os, 'getppid'):
|
||||
return os.getppid()
|
||||
elif psutil:
|
||||
return psutil.Process(os.getpid()).ppid()
|
||||
else:
|
||||
raise OSError('Your OS does not support `os.getppid`. Please install `psutil` as an alternative provider.')
|
||||
|
||||
Reference in New Issue
Block a user