Skip to content

Backports_lnbits_changes#8

Open
callebtc wants to merge 2 commits intomainfrom
backports_lnbits_changes
Open

Backports_lnbits_changes#8
callebtc wants to merge 2 commits intomainfrom
backports_lnbits_changes

Conversation

@callebtc
Copy link
Copy Markdown
Owner

Backports changes that we made in lnbits/nostrclient

Comment thread nostr/relay.py
Comment on lines +95 to +101
try:
message = self.queue.get(timeout=1)
self.num_sent_events += 1
self.ws.send(message)
except:
if shutdown():
break
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Can shutdown worker now via shutdown()

Comment thread nostr/relay.py
Comment on lines +134 to +137
if self.error_threshold and self.error_counter > self.error_threshold:
pass
else:
self.check_reconnect()
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Reconnect on error

Comment thread nostr/relay_manager.py
Comment on lines +30 to +33
self.relays[url].close()
self.relays.pop(url)
self.threads[url].join(timeout=1)
self.threads.pop(url)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Remove relays during runtime.

Comment thread nostr/relay_manager.py
Comment on lines +45 to +51
self.threads[relay.url] = threading.Thread(
target=relay.connect,
args=(ssl_options, proxy),
name=f"{relay.url}-thread",
daemon=True,
).start()
)
self.threads[relay.url].start()
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

We save all threads now.

Comment thread nostr/relay_manager.py
Comment on lines +53 to +59
self.queue_threads[relay.url] = threading.Thread(
target=relay.queue_worker,
args=(lambda: relay.shutdown,),
name=f"{relay.url}-queue",
daemon=True,
)
self.queue_threads[relay.url].start()
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

We also save all queue worker threads and add a shutdown argument

Comment thread nostr/client/client.py
callback_events_func(event_msg)
while self.relay_manager.message_pool.has_notices():
event_msg = self.relay_manager.message_pool.has_notices()
event_msg = self.relay_manager.message_pool.get_notice()
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Endless loop due to has_notice fixed.

vicariousdrama pushed a commit to vicariousdrama/python-nostr that referenced this pull request Oct 29, 2023
vicariousdrama added a commit to vicariousdrama/python-nostr that referenced this pull request Oct 29, 2023
@weex
Copy link
Copy Markdown

weex commented Nov 12, 2023

Looks good. Any reason not to merge?

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