Skip to content

Commit

Permalink
Adjust upload thread timings
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Easterbrook <jim@jim-easterbrook.me.uk>
  • Loading branch information
jim-easterbrook committed Apr 26, 2018
1 parent 87dc18f commit 08f5d34
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/pywws/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '18.4.2'
_release = '1523'
_commit = '092cf26'
_release = '1524'
_commit = '87dc18f'
16 changes: 10 additions & 6 deletions src/pywws/service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def run(self):
self.parent.logger.debug('thread started ' + self.name)
self.old_message = ''
if self.context.live_logging:
polling_interval = self.parent.interval.total_seconds() / 10
polling_interval = self.parent.interval.total_seconds() / 20
polling_interval = min(max(polling_interval, 4.0), 40.0)
else:
polling_interval = 4.0
while not self.context.shutdown.is_set():
Expand All @@ -59,7 +60,7 @@ def run(self):
pause = polling_interval
elif self.context.live_logging:
# upload failed, wait before trying again
pause = polling_interval * 10
pause = 40.0
else:
# upload failed or nothing more to do
break
Expand All @@ -79,11 +80,14 @@ def upload_batch(self):
while self.queue and not self.context.shutdown.is_set():
if self.parent.catchup == 0:
# "live only" service, so ignore old records
pending = len(self.queue)
drop = len(self.queue) - 1
if self.queue[-1] is None:
pending -= 1
for i in range(pending - 1):
self.queue.popleft()
drop -= 1
if drop > 0:
for i in range(drop):
self.queue.popleft()
self.parent.logger.warning(
'{:d} record(s) dropped'.format(drop))
# send upload without taking it off queue
upload = self.queue[0]
if upload is None:
Expand Down

0 comments on commit 08f5d34

Please sign in to comment.