python-nostr
python-nostr copied to clipboard
refactor relay threads
Relay class
- Add thread instantiation to
connect
method - Add
is_connected
method which checks if thews.run_forever
thread is alive. I think this is more reliable because this thread will be torn down on disconnect. - Various renaming
Relay Manager
- Remove thread instantiation from
add_relay
(handled inrelay.connect
now) - Add
relay_connection_monitor
thread, which periodically (connection_monitor_interval_secs
) checks if the relays are disconnected and reconnects them if they are.
Note: I felt like reconnection logic belongs in the relay manager as it's job is to manage the relays