show currently running process updates
This commit is contained in:
parent
ab868f41c9
commit
d5477c8b75
3 changed files with 13 additions and 0 deletions
|
@ -32,6 +32,12 @@
|
|||
{% endif %}
|
||||
{{ last_processed|date:"SHORT_DATETIME_FORMAT" }}
|
||||
{% endif %}
|
||||
{% if last_processed_start %}
|
||||
{% if not last_processed or last_processed < last_processed_start %}
|
||||
{% trans 'Currently running since:' %}
|
||||
{{ last_processed_start|date:"SHORT_DATETIME_FORMAT" }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</p>
|
||||
<button type="submit" name="process_updates" value="1">{% trans 'Process map updates now' %}</button>
|
||||
</form>
|
||||
|
|
|
@ -394,8 +394,13 @@ def map_updates(request):
|
|||
if last_processed:
|
||||
last_processed = make_aware(datetime.fromtimestamp(last_processed))
|
||||
|
||||
last_processed_start = cache.get('mapdata:last_process_updates_start', None)
|
||||
if last_processed_start:
|
||||
last_processed_start = make_aware(datetime.fromtimestamp(last_processed_start))
|
||||
|
||||
return render(request, 'control/map_updates.html', {
|
||||
'last_processed': last_processed,
|
||||
'last_processed_start': last_processed_start,
|
||||
'last_processed_success': last_processed_success,
|
||||
'auto_process_updates': settings.AUTO_PROCESS_UPDATES,
|
||||
'map_update_form': map_update_form,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
import os
|
||||
import pickle
|
||||
import time
|
||||
from contextlib import contextmanager, suppress
|
||||
from sqlite3 import DatabaseError
|
||||
|
||||
|
@ -121,6 +122,7 @@ class MapUpdate(models.Model):
|
|||
lock_aquired = lock.acquire(blocking=False, blocking_timeout=1800)
|
||||
if not lock_aquired:
|
||||
raise cls.ProcessUpdatesAlreadyRunning
|
||||
cache.set('mapdata:last_process_updates_start', int(time.time()), None)
|
||||
yield tuple(queryset)
|
||||
finally:
|
||||
if lock_aquired:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue