Skip to content

Commit

Permalink
fixed race condition between watchdog reacting to new files and watch…
Browse files Browse the repository at this point in the history
…dog checking for files at specific intervals; logging now distinguishes between DEBUG/INFO/ERROR levels; keyboard interrupts via CTRL+C are now handled correctly; in watchdog mode, an initial scan of the input directory is now performed, in case files were already present; prepared for release
  • Loading branch information
fracpete committed Dec 10, 2020
1 parent f4daa02 commit d98d9d6
Show file tree
Hide file tree
Showing 5 changed files with 262 additions and 165 deletions.
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

0.0.6 (2020-12-10)
------------------

- fixed race condition between watchdog reacting to new files and watchdog checking for files at specific intervals
- logging now distinguishes between DEBUG/INFO/ERROR levels
- keyboard interrupts via CTRL+C are now handled correctly
- in watchdog mode, an initial scan of the input directory is now performed, in case files were already present


0.0.5 (2020-12-10)
------------------

Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,11 @@ print("Stopped?", p.is_stopped())
## Custom logging

By suppplying a method to the `logging` option, you can custom the logging
that occurs. The example below uses the Python logging framework.
that occurs via the `info`, `debug` and `error` method calls of the Poller.
The example below uses the Python logging framework.

```python
from sfp import Poller
from sfp import Poller, LOGGING_TYPE_INFO, LOGGING_TYPE_DEBUG, LOGGING_TYPE_ERROR
import logging

_logger = None
Expand All @@ -135,7 +136,12 @@ def custom_logging(*args):
_logger = logging.getLogger("sfp")
_logger.setLevel(logging.DEBUG)
str_args = [str(x) for x in args]
_logger.info(" ".join(str_args))
if type == LOGGING_TYPE_ERROR:
_logger.error(" ".join(str_args))
elif type == LOGGING_TYPE_DEBUG:
_logger.debug(" ".join(str_args))
else:
_logger.info(" ".join(str_args))

p = Poller()
# ... setting more options
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _read(f):
install_requires=[
"watchdog",
],
version="0.0.5",
version="0.0.6",
author='Peter Reutemann',
author_email='fracpete@waikato.ac.nz',
)
2 changes: 1 addition & 1 deletion src/sfp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from ._poller import Poller, Parameters, dummy_file_check, dummy_file_processing, simple_logging
from ._poller import GLOB_NAME_PLACEHOLDER
from ._poller import GLOB_NAME_PLACEHOLDER, LOGGING_TYPE_DEBUG, LOGGING_TYPE_INFO, LOGGING_TYPE_ERROR
Loading

0 comments on commit d98d9d6

Please # to comment.