Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing a bug with per-request timeout #11

Merged
merged 1 commit into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lightbeam/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def prepare(self, selector="*"):
# Returns a client object with exponential retry and other parameters per configs
def get_retry_client(self):
return RetryClient(
timeout=aiohttp.ClientTimeout(total=self.lightbeam.config['connection']["timeout"]),
timeout=aiohttp.ClientTimeout(sock_connect=self.lightbeam.config['connection']["timeout"]),
retry_options=ExponentialRetry(
attempts=self.lightbeam.config['connection']["num_retries"],
factor=self.lightbeam.config['connection']["backoff_factor"],
Expand Down
23 changes: 12 additions & 11 deletions lightbeam/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ async def do_send(self, endpoint):

# Posts a single data payload to a single endpoint using the client
async def do_post(self, endpoint, file_name, data, client, line, hash):
try:
status = 401
while status==401:
# wait if another process has locked lightbeam while we refresh the oauth token:
while self.lightbeam.is_locked:
await asyncio.sleep(1)
status = 401
while status==401:

# wait if another process has locked lightbeam while we refresh the oauth token:
while self.lightbeam.is_locked:
await asyncio.sleep(1)

try:
async with client.post(util.url_join(self.lightbeam.api.config["data_url"], self.lightbeam.config["namespace"], endpoint),
data=data,
ssl=self.lightbeam.config["connection"]["verify_ssl"],
Expand Down Expand Up @@ -122,7 +122,8 @@ async def do_post(self, endpoint, file_name, data, client, line, hash):
else:
self.lightbeam.api.update_oauth()

except Exception as e:
self.lightbeam.num_errors += 1
self.logger.warn("{0} (at line {1} of {2} )".format(str(e), line, file_name))
except Exception as e:
status = 400
self.lightbeam.num_errors += 1
self.logger.warn("{0} (at line {1} of {2} )".format(str(e), line, file_name))