Skip to content

Conversation

@callebtc
Copy link
Owner

Backports changes that we made in lnbits/nostrclient

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
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 on lines +134 to +137
if self.error_threshold and self.error_counter > self.error_threshold:
pass
else:
self.check_reconnect()
Copy link
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 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
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 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
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 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
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

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
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

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.

3 participants