Skip to content

Merge Daemon features into master#1

Open
Snapple49 wants to merge 15 commits into
masterfrom
daemon_features
Open

Merge Daemon features into master#1
Snapple49 wants to merge 15 commits into
masterfrom
daemon_features

Conversation

@Snapple49
Copy link
Copy Markdown

Added some features about timeout, exiting when container does not get any requests within specified timeout period and requesting from master permission to self terminate, freeing up system resources

Comment thread harmonicPE/daemon.py Outdated
af, socktype, proto, canonname, sa = res
try:
listening_socket = socket.socket(af, socktype, proto)
listening_socket.settimeout(Setting.get_idle_timeout()) # set the socket timeout to specified value from Settings, if not specified acts as if nothing changed
Copy link
Copy Markdown
Member

@benblamey benblamey Apr 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment?
(this is reliant on use of 'blocking' socket.listen below)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to wrap this inside an 'if not none:' - more robust that way (incase the socket API changes in the future, etc.)

Copy link
Copy Markdown
Author

@Snapple49 Snapple49 Apr 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, that is safer if they ever change those things, didn't think it's likely but better safe than sorry. Fixed!

Comment thread harmonicPE/daemon.py Outdated
restarted = False
except socket.timeout as t:
# graceful container exit - notify master I am quitting
import requests, os
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imports at the top

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants