I tried to write a simple Python plug-in for the Hexchat IRC client. However, it seems it is not thread-safe and causes that Hexchat crashes.
__module_name__ = "Demo"
__module_version__ = "1.0"
__module_description__ = "Demo plug-in"
import hexchat
from threading import Thread
from time import sleep
def sleep10seconds():
hexchat.prnt("before sleep")
sleep(10)
hexchat.prnt("sleep end")
hexchat.command("server " + hexchat.get_info("host"))
return
# This function is called when a "disconnected" print event was found
def disconnected_cb(word, word_eol, userdata):
# The sleep() needs to run in a separate thread. Otherwise, the UI
# freezes for the time of the sleep()
myThread = Thread(target=sleep10seconds)
myThread.start()
return hexchat.EAT_NONE
hexchat.command("discon")
hexchat.command("server " + hexchat.get_info("host"))
hexchat.hook_print("Disconnected", disconnected_cb)
I read some articles about thread safety, but I'm not a developer. I couldn't figure out what I need to change. Can you please help me? Thanks.
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
Want to improve this question? Update the question so it's on-topic for Stack Overflow
so I'm trying to create an app like Proxifier which lets you choose what application you want to run through proxyI tried PySocks but it seems it is only capable to connect to websites
I have already gone through similar questions on the forum, but did not find anyone solving my query
I have created multipleline plot that shows data about different plantsRight now the legend is based on index of numbers that was creates as defult