send 50 offline heartbeats per request with one second delay in between
This commit is contained in:
parent
34702c91aa
commit
a1369a2b00
4 changed files with 6 additions and 2 deletions
|
@ -27,6 +27,7 @@ from .utils import ANY, CustomResponse
|
||||||
|
|
||||||
class MainTestCase(utils.TestCase):
|
class MainTestCase(utils.TestCase):
|
||||||
patch_these = [
|
patch_these = [
|
||||||
|
'time.sleep',
|
||||||
'wakatime.packages.requests.adapters.HTTPAdapter.send',
|
'wakatime.packages.requests.adapters.HTTPAdapter.send',
|
||||||
'wakatime.offlinequeue.Queue.push',
|
'wakatime.offlinequeue.Queue.push',
|
||||||
['wakatime.offlinequeue.Queue.pop', None],
|
['wakatime.offlinequeue.Queue.pop', None],
|
||||||
|
|
|
@ -20,6 +20,7 @@ from .utils import mock, json, ANY, CustomResponse, NamedTemporaryFile, Temporar
|
||||||
|
|
||||||
class OfflineQueueTestCase(TestCase):
|
class OfflineQueueTestCase(TestCase):
|
||||||
patch_these = [
|
patch_these = [
|
||||||
|
'time.sleep',
|
||||||
'wakatime.packages.requests.adapters.HTTPAdapter.send',
|
'wakatime.packages.requests.adapters.HTTPAdapter.send',
|
||||||
'wakatime.session_cache.SessionCache.save',
|
'wakatime.session_cache.SessionCache.save',
|
||||||
'wakatime.session_cache.SessionCache.delete',
|
'wakatime.session_cache.SessionCache.delete',
|
||||||
|
|
|
@ -46,11 +46,11 @@ Default is 2MB.
|
||||||
"""
|
"""
|
||||||
MAX_FILE_SIZE_SUPPORTED = 2000000
|
MAX_FILE_SIZE_SUPPORTED = 2000000
|
||||||
|
|
||||||
""" Default number of offline heartbeats to sync before exiting."""
|
""" Default limit of number of offline heartbeats to sync before exiting."""
|
||||||
DEFAULT_SYNC_OFFLINE_ACTIVITY = 100
|
DEFAULT_SYNC_OFFLINE_ACTIVITY = 100
|
||||||
|
|
||||||
""" Number of heartbeats per api request.
|
""" Number of heartbeats per api request.
|
||||||
Even when sending more heartbeats, this is the number of heartbeats sent per
|
Even when sending more heartbeats, this is the number of heartbeats sent per
|
||||||
individual https request to the WakaTime API.
|
individual https request to the WakaTime API.
|
||||||
"""
|
"""
|
||||||
HEARTBEATS_PER_REQUEST = 10
|
HEARTBEATS_PER_REQUEST = 50
|
||||||
|
|
|
@ -14,6 +14,7 @@ from __future__ import print_function
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
pwd = os.path.dirname(os.path.abspath(__file__))
|
pwd = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
@ -76,6 +77,7 @@ def execute(argv=None):
|
||||||
if retval == SUCCESS:
|
if retval == SUCCESS:
|
||||||
queue = Queue(args, configs)
|
queue = Queue(args, configs)
|
||||||
for offline_heartbeats in queue.pop_many(args.sync_offline_activity):
|
for offline_heartbeats in queue.pop_many(args.sync_offline_activity):
|
||||||
|
time.sleep(1)
|
||||||
retval = send_heartbeats(offline_heartbeats, args, configs)
|
retval = send_heartbeats(offline_heartbeats, args, configs)
|
||||||
if retval != SUCCESS:
|
if retval != SUCCESS:
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue