-
Notifications
You must be signed in to change notification settings - Fork 713
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
Content import peer discovery #6011
Conversation
(also means that we start with a soft interrupt and only hard-kill later if needed, as we do on Linux)
"""Retrieve a list of dicts with information about the discovered Kolibri instances on the local network, | ||
filtering out those that can't be accessed at the specified port (via attempting to open a socket).""" | ||
if not ZEROCONF_STATE["listener"]: | ||
initialize_zeroconf_listener() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be taken out so that we don't end up with multiple zeroconf listeners.
Instead, the single zeroconf listener will pickle the latest list of instances, and various workers will access the pickled list.
continue | ||
if not _is_port_open(instance["ip"], instance["port"], timeout=timeout): | ||
continue | ||
instance["self"] = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will get moved into the zeroconf discovery handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and can just be excluded off the bat)
|
||
|
||
def _is_port_open(host, port, timeout=1): | ||
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a little local cache so that this check isn't done too frequently for a given peer, but so that the check is done:
- immediately following discovery
- after a while (~ 20 seconds?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest having it be a "shared" cache (not just local memory), using Django's cache backend, because it might be different web service processes handling the sequential queries.
Codecov Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome thanks @micahscopes
There are a few outstanding notes from @jamalex and I left a few very minor comments also. I'll merge this in and we'll continue the work in subsequent PRs
Also opened this: #6059
@@ -5,6 +5,7 @@ | |||
v-if="stage === Stages.SELECT_ADDRESS" | |||
@cancel="resetContentWizardState" | |||
@click_add_address="goToAddAddress" | |||
@click_search_address="goToSearchAddress" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conventionally we use camelCase
for events. I see that this matches the others in the component so this is fine, but would be nice to refactor later for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I didn't bother to go that in-depth. That code is copied from another file and looking at it now, is going to be deleted anyway.
/> | ||
</div> | ||
</template> | ||
|
||
<hr v-if="discoveredAddresses.length > 0"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in subsequent work, let's make sure this is styled as a one-pixel solid line using the theme color $themeTokens.fineLine
this.intervalId = clearInterval(this.intervalId); | ||
} | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as in another PR here: #5631 (comment)
Woot |
Summary
builds off of #5660
Reviewer guidance
Work-in-progress
References
#5660
Contributor Checklist
PR process:
Testing:
Reviewer Checklist
yarn
andpip
)