Skip to content

Commit

Permalink
Fixed inotify stop for workers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien Delle Cave committed Jan 5, 2020
1 parent 5c1e45a commit 727ea5f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
python-dwho (0.3.20) unstable; urgency=medium

* Fixed inotify stop for workers.

-- Adrien DELLE CAVE (Decryptus) <adc@doowan.net> Sun, 05 Jan 2020 14:57:43 +0100

python-dwho (0.3.19) unstable; urgency=medium

* Fixed subproc notifier.
Expand Down
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.19
0.3.20
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.19
0.3.20
5 changes: 5 additions & 0 deletions dwho/classes/inoplugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def register(self, plugin):
raise TypeError("Invalid Inotify Plugin class. (class: %r)" % plugin)
return dict.__setitem__(self, plugin.PLUGIN_NAME, plugin)

def unregister(self, plugin):
if not isinstance(plugin, DWhoInoPlugBase):
raise TypeError("Invalid Inotify Plugin class. (class: %r)" % plugin)
return dict.__delitem__(self, plugin.PLUGIN_NAME)

INOPLUGS = DWhoInoPlugs()


Expand Down
4 changes: 3 additions & 1 deletion dwho/classes/inotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,9 @@ def run(self):

def stop(self):
self.killed = True
self.workerpool.killall(0)
self.scan_event.set()
if self.workerpool:
self.workerpool.killall(0)


class DWhoInotifyPlugs(threading.Thread):
Expand Down
10 changes: 6 additions & 4 deletions dwho/classes/notifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@ def __call__(self, xvars = None):
xvars = {}

nvars = copy.deepcopy(xvars)
nvars['_VARS_'] = copy.deepcopy(xvars)
nvars['_SERVER_ID_'] = self.server_id
nvars['_TIMESTAMP_'] = time.time()
nvars['_ENV_'] = copy.deepcopy(os.environ)
nvars['_TIME_'] = datetime.now()
nvars['_GMTIME_'] = datetime.utcnow()
nvars['_HOSTNAME_'] = getfqdn()
nvars['_SERVER_ID_'] = self.server_id
nvars['_TIME_'] = datetime.now()
nvars['_TIMESTAMP_'] = time.time()
nvars['_UUID_'] = "%s" % uuid.uuid4()
nvars['_VARS_'] = copy.deepcopy(xvars)

for name, notification in six.iteritems(self.notifications):
if not notification['cfg']['general'].get('enabled', True):
Expand Down Expand Up @@ -196,6 +197,7 @@ class DWhoNotifierSubprocess(DWhoNotifierBase):
@staticmethod
def _set_default_env(env, xvars):
env.update({'DWHO_NOTIFIER': 'true',
'DWHO_NOTIFIER_HOSTNAME': "%s" % getfqdn(),
'DWHO_NOTIFIER_GMTIME': "%s" % xvars['_GMTIME_'],
'DWHO_NOTIFIER_TIME': "%s" % xvars['_TIME_'],
'DWHO_NOTIFIER_TIMESTAMP': "%s" % xvars['_TIMESTAMP_'],
Expand Down
6 changes: 3 additions & 3 deletions setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: dwho
description: dwho
author: Adrien Delle Cave
author_email: pypi@doowan.net
copyright: '2019 Adrien Delle Cave'
release: '0.3.19'
version: '0.3.19'
copyright: '2020 Adrien Delle Cave'
release: '0.3.20'
version: '0.3.20'
license: License GPL-3
url: https://github.com/decryptus/dwho
python_requires:
Expand Down

0 comments on commit 727ea5f

Please sign in to comment.