1 From 478d595a7d086423733e9f5da5edfe9f1df48682 Mon Sep 17 00:00:00 2001
2 From: Troy Curtis Jr <troy@troycurtisjr.com>
3 Date: Thu, 10 Aug 2023 21:51:15 -0400
4 Subject: [PATCH] Make asyncore support optional for Python 3.
8 python3/pyinotify.py | 50 +++++++++++++++++++++++++-------------------
9 1 file changed, 28 insertions(+), 22 deletions(-)
11 diff --git a/python3/pyinotify.py b/python3/pyinotify.py
12 index bc24313..f4a5a90 100755
13 --- a/python3/pyinotify.py
14 +++ b/python3/pyinotify.py
15 @@ -68,7 +68,6 @@ def __init__(self, version):
16 from datetime import datetime, timedelta
23 @@ -1494,33 +1493,40 @@ def run(self):
27 -class AsyncNotifier(asyncore.file_dispatcher, Notifier):
29 - This notifier inherits from asyncore.file_dispatcher in order to be able to
30 - use pyinotify along with the asyncore framework.
35 - def __init__(self, watch_manager, default_proc_fun=None, read_freq=0,
36 - threshold=0, timeout=None, channel_map=None):
37 + class AsyncNotifier(asyncore.file_dispatcher, Notifier):
39 - Initializes the async notifier. The only additional parameter is
40 - 'channel_map' which is the optional asyncore private map. See
41 - Notifier class for the meaning of the others parameters.
42 + This notifier inherits from asyncore.file_dispatcher in order to be able to
43 + use pyinotify along with the asyncore framework.
46 - Notifier.__init__(self, watch_manager, default_proc_fun, read_freq,
48 - asyncore.file_dispatcher.__init__(self, self._fd, channel_map)
49 + def __init__(self, watch_manager, default_proc_fun=None, read_freq=0,
50 + threshold=0, timeout=None, channel_map=None):
52 + Initializes the async notifier. The only additional parameter is
53 + 'channel_map' which is the optional asyncore private map. See
54 + Notifier class for the meaning of the others parameters.
56 - def handle_read(self):
58 - When asyncore tells us we can read from the fd, we proceed processing
59 - events. This method can be overridden for handling a notification
62 + Notifier.__init__(self, watch_manager, default_proc_fun, read_freq,
64 + asyncore.file_dispatcher.__init__(self, self._fd, channel_map)
68 - self.process_events()
69 + def handle_read(self):
71 + When asyncore tells us we can read from the fd, we proceed processing
72 + events. This method can be overridden for handling a notification
77 + self.process_events()
79 + # asyncore was removed in Python 3.12, but try the import instead of a
80 + # version check in case the compatibility package is installed.
84 class TornadoAsyncNotifier(Notifier):