python - 带有不和谐 RPC 的 Python 线程
问题描述
问题:它不运行thread_3 什么是thread_3?它是一个不和谐的 rpc(例如连接到您的不和谐应用程序:您可以使用它设置游戏活动)我不知道为什么它不起作用。我是多线程/线程的新手。也许有人可以帮助我,谢谢!
import _thread as thread
import time
from pypresence import Presence
cid = int(785560652756418621)
rpc = Presence(cid)
# Define a function for the thread
def print_time( threadName, delay):
count = 0
while count == count:
time.sleep(delay)
count += 1
print ("%s: %s" % ( threadName, time.ctime(time.time()) ))
def print_test( threadName, delay):
count = 0
while count == count:
time.sleep(delay)
count += 1
print ("%s: %s" % ( threadName, delay))
def thread_3(delay):
count = 0
while count == count:
time.sleep(delay)
count += 1
# Connect to Discord
rpc.connect()
rpc.update(small_image = '512', large_image = '512',state = "Test",details = "Test", small_text="Test", large_text="Test")
print('RPC set successfully.')
# Update RPC every 15 seconds
while True:
time.sleep(10)
# Create two threads as follows
try:
thread.start_new_thread( print_time, ("Thread-1", 2) )
# thread.start_new_thread( print_test, ("Thread-2", 4) )
thread.start_new_thread( thread_3, ("Discord-3", 3) )
except:
print ("Error: unable to start thread")
while 1:
pass
解决方案
推荐阅读
- c# - 为什么 if 语句有效但 switch 语句无效
- amazon-web-services - How do I run my CDK app?
- android - 二进制 XML 文件行在可绘制对象中膨胀类按钮时出错
- excel - 从 Laravel 后端使用 Axios 下载 Excel 数据不起作用
- android - DAO 查询不适用于 MIN MAX 函数
- excel - 当您在 Excel 中有很多字段要绑定时,添加绑定和获取绑定的最佳方法是什么。Office.js
- regex - 正则表达式与带引号的 perl 匹配
- c# - 在淘汰赛中从 Enum 中获取价值
- python - Python:如何为所有变量生成频率计数
- javascript - 在自定义搜索中抓取 JSON 图像