python - 对象没有被存储和从多处理队列中提取
问题描述
import discord
import pyboy
import multiprocessing
from discord.ext import commands
from pyboy import PyBoy, WindowEvent
client = commands.Bot(command_prefix = ',')
pyboy = PyBoy('pokemonYellow.gb', sound=True)
q = multiprocessing.Queue()
def token():
return client.run('')
def emulator():
pyboy = PyBoy('pokemonYellow.gb', sound=True)
while True:
try:
pyboy.send_input(q.get_nowait())
except:
pass
if pyboy.tick():
return
@client.command(brief = "presses the start button")
async def start(ctx):
q.put(WindowEvent.PRESS_BUTTON_START)
@client.command(brief = "presses the select button")
async def select(ctx):
q.put(WindowEvent.PRESS_BUTTON_SELECT)
@client.command(brief = "presses the a button")
async def a(ctx):
q.put(WindowEvent.PRESS_BUTTON_A)
@client.command(brief = "presses the b button")
async def b(ctx):
q.put(WindowEvent.PRESS_BUTTON_B)
@client.command(brief = "presses the up button")
async def up(ctx):
q.put(WindowEvent.PRESS_ARROW_UP)
@client.command(brief = "presses the down button")
async def down(ctx):
q.put(WindowEvent.PRESS_ARROW_DOWN)
@client.command(brief = "presses the left button")
async def left(ctx):
q.put(WindowEvent.PRESS_ARROW_LEFT)
@client.command(brief = "presses the right button")
async def right(ctx):
q.put(WindowEvent.PRESS_ARROW_RIGHT)
def main():
process1 = multiprocessing.Process(target = token)
process2 = multiprocessing.Process(target = emulator)
process1.start()
process2.start()
if __name__ == "__main__":
main()
afai 可以判断对象正在被放入队列中,但是有东西正在吃掉它们并且它们没有出来。任何帮助,将不胜感激。我也尝试将 discord.py 的东西扔到它自己的函数中,但这没有帮助。由于 pyboy 的怪异行为,我不能为此使用线程。
解决方案
推荐阅读
- python - 如何从站点获取所有页面数据并保存?
- sql-server - SQL Server 和 Vb.net 中的关系问题
- vuetify.js - vuelidate 中的表单验证
- python - 使用可变长度参数并希望让用户给出灵活大小的实际参数
- python - /'str'对象的TypeError不是django模板中的映射
- react-native - 我想在 React Native 中实现类似的背景但不知道该怎么做?
- android - 如何在 gui 中启动 androidx86?
- cypress - 断言 Cypress 路由是否只调用一次
- python - 如何使用pyqt4将字典键数据项列表添加到QTableWidget中
- python-3.x - 将三个列表合并在一起,使每个第 n 项对应于其他列表的第 n 项