mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	added option for polling
This commit is contained in:
		| @@ -6,6 +6,7 @@ from django.core.management.base import BaseCommand | ||||
| from django_q.tasks import async_task | ||||
| from watchdog.events import FileSystemEventHandler | ||||
| from watchdog.observers import Observer | ||||
| from watchdog.observers.polling import PollingObserver | ||||
|  | ||||
| try: | ||||
|     from inotify_simple import INotify, flags | ||||
| @@ -75,7 +76,12 @@ class Command(BaseCommand): | ||||
|                 async_task("documents.tasks.consume_file", entry.path, task_name=os.path.basename(entry.path)) | ||||
|  | ||||
|         # Start the watchdog. Woof! | ||||
|         observer = Observer() | ||||
|         if settings.CONSUMER_POLLING > 0: | ||||
|             logging.getLogger(__name__).info('Using polling instead of file' | ||||
|                                              'system notifications.') | ||||
|             observer = PollingObserver(timeout=settings.CONSUMER_POLLING) | ||||
|         else: | ||||
|             observer = Observer() | ||||
|         event_handler = Handler() | ||||
|         observer.schedule(event_handler, directory, recursive=True) | ||||
|         observer.start() | ||||
|   | ||||
| @@ -286,13 +286,29 @@ TASK_WORKERS = int(os.getenv("PAPERLESS_TASK_WORKERS", default_task_workers())) | ||||
| Q_CLUSTER = { | ||||
|     'name': 'paperless', | ||||
|     'catch_up': False, | ||||
|     'workers': TASK_WORKERS, | ||||
|     'redis': os.getenv("PAPERLESS_REDIS", "redis://localhost:6379") | ||||
| } | ||||
|  | ||||
|  | ||||
| def default_threads_per_worker(): | ||||
|     try: | ||||
|         return max( | ||||
|             math.floor(multiprocessing.cpu_count() / TASK_WORKERS), | ||||
|             1 | ||||
|         ) | ||||
|     except NotImplementedError: | ||||
|         return 1 | ||||
|  | ||||
|  | ||||
| THREADS_PER_WORKER = os.getenv("PAPERLESS_THREADS_PER_WORKER", default_threads_per_worker()) | ||||
|  | ||||
| ############################################################################### | ||||
| # Paperless Specific Settings                                                 # | ||||
| ############################################################################### | ||||
|  | ||||
| CONSUMER_POLLING = int(os.getenv("PAPERLESS_CONSUMER_POLLING", 0)) | ||||
|  | ||||
| CONSUMER_DELETE_DUPLICATES = __get_boolean("PAPERLESS_CONSUMER_DELETE_DUPLICATES") | ||||
|  | ||||
| # The default language that tesseract will attempt to use when parsing | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jonas Winkler
					Jonas Winkler