diff options
Diffstat (limited to 'bitbake/lib/pyinotify.py')
-rw-r--r-- | bitbake/lib/pyinotify.py | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/bitbake/lib/pyinotify.py b/bitbake/lib/pyinotify.py index 6ae40a2d76..3c5dab0312 100644 --- a/bitbake/lib/pyinotify.py +++ b/bitbake/lib/pyinotify.py | |||
@@ -52,7 +52,6 @@ from collections import deque | |||
52 | from datetime import datetime, timedelta | 52 | from datetime import datetime, timedelta |
53 | import time | 53 | import time |
54 | import re | 54 | import re |
55 | import asyncore | ||
56 | import glob | 55 | import glob |
57 | import locale | 56 | import locale |
58 | import subprocess | 57 | import subprocess |
@@ -596,14 +595,24 @@ class _ProcessEvent: | |||
596 | @type event: Event object | 595 | @type event: Event object |
597 | @return: By convention when used from the ProcessEvent class: | 596 | @return: By convention when used from the ProcessEvent class: |
598 | - Returning False or None (default value) means keep on | 597 | - Returning False or None (default value) means keep on |
599 | executing next chained functors (see chain.py example). | 598 | executing next chained functors (see chain.py example). |
600 | - Returning True instead means do not execute next | 599 | - Returning True instead means do not execute next |
601 | processing functions. | 600 | processing functions. |
602 | @rtype: bool | 601 | @rtype: bool |
603 | @raise ProcessEventError: Event object undispatchable, | 602 | @raise ProcessEventError: Event object undispatchable, |
604 | unknown event. | 603 | unknown event. |
605 | """ | 604 | """ |
606 | stripped_mask = event.mask - (event.mask & IN_ISDIR) | 605 | stripped_mask = event.mask & ~IN_ISDIR |
606 | # Bitbake hack - we see event masks of 0x6, i.e., IN_MODIFY & IN_ATTRIB. | ||
607 | # The kernel inotify code can set more than one of the bits in the mask, | ||
608 | # fsnotify_change() in linux/fsnotify.h is quite clear that IN_ATTRIB, | ||
609 | # IN_MODIFY and IN_ACCESS can arrive together. | ||
610 | # This breaks the code below which assume only one mask bit is ever | ||
611 | # set in an event. We don't care about attrib or access in bitbake so | ||
612 | # drop those. | ||
613 | if stripped_mask & IN_MODIFY: | ||
614 | stripped_mask &= ~(IN_ATTRIB | IN_ACCESS) | ||
615 | |||
607 | maskname = EventsCodes.ALL_VALUES.get(stripped_mask) | 616 | maskname = EventsCodes.ALL_VALUES.get(stripped_mask) |
608 | if maskname is None: | 617 | if maskname is None: |
609 | raise ProcessEventError("Unknown mask 0x%08x" % stripped_mask) | 618 | raise ProcessEventError("Unknown mask 0x%08x" % stripped_mask) |
@@ -1475,35 +1484,6 @@ class ThreadedNotifier(threading.Thread, Notifier): | |||
1475 | self.loop() | 1484 | self.loop() |
1476 | 1485 | ||
1477 | 1486 | ||
1478 | class AsyncNotifier(asyncore.file_dispatcher, Notifier): | ||
1479 | """ | ||
1480 | This notifier inherits from asyncore.file_dispatcher in order to be able to | ||
1481 | use pyinotify along with the asyncore framework. | ||
1482 | |||
1483 | """ | ||
1484 | def __init__(self, watch_manager, default_proc_fun=None, read_freq=0, | ||
1485 | threshold=0, timeout=None, channel_map=None): | ||
1486 | """ | ||
1487 | Initializes the async notifier. The only additional parameter is | ||
1488 | 'channel_map' which is the optional asyncore private map. See | ||
1489 | Notifier class for the meaning of the others parameters. | ||
1490 | |||
1491 | """ | ||
1492 | Notifier.__init__(self, watch_manager, default_proc_fun, read_freq, | ||
1493 | threshold, timeout) | ||
1494 | asyncore.file_dispatcher.__init__(self, self._fd, channel_map) | ||
1495 | |||
1496 | def handle_read(self): | ||
1497 | """ | ||
1498 | When asyncore tells us we can read from the fd, we proceed processing | ||
1499 | events. This method can be overridden for handling a notification | ||
1500 | differently. | ||
1501 | |||
1502 | """ | ||
1503 | self.read_events() | ||
1504 | self.process_events() | ||
1505 | |||
1506 | |||
1507 | class TornadoAsyncNotifier(Notifier): | 1487 | class TornadoAsyncNotifier(Notifier): |
1508 | """ | 1488 | """ |
1509 | Tornado ioloop adapter. | 1489 | Tornado ioloop adapter. |