jeffthibault / python-nostr

A Python library for Nostr
MIT License
274 stars 87 forks source link

Attribute Error: 'RelayManager' object has no attribute 'lock' #73

Closed noubre closed 1 year ago

noubre commented 1 year ago

I am getting this error:

image

Using this code:

import time
import threading
from nostr.relay_manager import RelayManager
import logging

logging.basicConfig(level=logging.INFO)

def main():
    relay_manager = RelayManager()
    relay_manager.add_relay("wss://nostr.zebedee.cloud")
    relay_manager.add_relay("wss://nostr.bitcoiner.social")
    logging.info(f"Connections opened: ")  # add more logging info
    time.sleep(1.25)  # allow the connections to open
    threading.Thread(target=run, args=(relay_manager,)).start()

def run(relay_manager):
    with relay_manager.lock:
        relay_manager.close_all_relay_connections()
        logging.info(f"Connections closed ...")

I saw a similar error already reported. I can't figure out how to fix it, it could easily be my own error as I am not very experienced using threading or locks.

Thanks!