Skip to content

Commit

Permalink
Merge pull request #81 from benoitblanc/generate-thumbnail-timeout
Browse files Browse the repository at this point in the history
Add configurable timeout for generating thumbnail
  • Loading branch information
manisandro authored Oct 4, 2024
2 parents c847713 + 7f02c7e commit 41cd88b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions schemas/qwc-config-generator.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@
"use_default_map_thumbnail": {
"description": "Whether to use the default mapthumb (mapthumbs/default.jpg) instead of generating the thumbnail via GetMap if no custom thumbnail is provided. Default: false"
},
"generate_thumbnail_timeout": {
"description": "Timeout for GetMap request when generating thumbnail. Default: 10sec",
"type": "number"
},
"ignore_errors": {
"description": "Ignore errors during generation to allow creating configuration files despite some errors. Default: false",
"type": "boolean"
Expand Down
7 changes: 6 additions & 1 deletion src/config_generator/map_viewer_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ def __init__(self, tenant_path, generator_config, themes_reader,
'use_default_map_thumbnail', False
)

# Timeout for generating thumbnail via GetMap request
self.generate_thumbnail_timeout = generator_config.get(
"generate_thumbnail_timeout", 10
)

# keep track of theme IDs for uniqueness
self.theme_ids = []

Expand Down Expand Up @@ -604,7 +609,7 @@ def get_thumbnail(self, cfg_item, service_name, capabilities, assets_dir):
'BBOX': (",".join(map(str, adjustedExtent))),
'LAYERS': (",".join(layers).encode('utf-8'))
},
timeout=10
timeout=self.generate_thumbnail_timeout
)

if response.status_code != requests.codes.ok:
Expand Down

0 comments on commit 41cd88b

Please sign in to comment.