Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
keelerm84 committed Aug 12, 2024
1 parent 4bfcdb8 commit f6341be
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ jobs:
- name: Run tests
run: make test

- run: make test
- run: make test
- run: make test
- run: make test
- run: make test
- run: make test
- run: make test
- run: make test

- name: Verify typehints
run: make lint

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ install:
.PHONY: test
test: #! Run unit tests
test: install
@poetry run pytest $(PYTEST_FLAGS)
@poetry run pytest $(PYTEST_FLAGS) ldclient/testing/test_file_data_source.py::test_reloads_modified_file_in_polling_mode

.PHONY: lint
lint: #! Run type analysis and linting checks
Expand Down
7 changes: 7 additions & 0 deletions ldclient/impl/integrations/files/file_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
import os
import traceback
import time
from logging import getLogger
from typing import Optional

logger = getLogger('@@@@@')

have_yaml = False
try:
import yaml
Expand Down Expand Up @@ -191,17 +194,21 @@ def __init__(self, resolved_paths, reloader, interval):
self._file_times = self._check_file_times()
self._timer = RepeatingTask(interval, interval, self._poll)
self._timer.start()
logger.warning('Using the polling file watcher because the watchdog package is not installed')

def stop(self):
self._timer.stop()

def _poll(self):
logger.warning('Polling for changes to data files')
new_times = self._check_file_times()
changed = False
for file_path, file_time in self._file_times.items():
if new_times.get(file_path) is not None and new_times.get(file_path) != file_time:
logger.warning('CHANGES detected in %s' % file_path)
changed = True
break
logger.warning('No changes detected in %s' % file_path)
self._file_times = new_times
if changed:
self._reloader()
Expand Down

0 comments on commit f6341be

Please sign in to comment.