相关疑难解决方法(0)

多处理管道 send() 块

根据 Python 文档,只有recv()块而不是send(). 我写了以下代码试图制作一个 GUI 数独游戏。我这样做的方式是,即使tkinter正在执行其mainloop. 但是,在测试运行期间,我发现如果我在游戏更新时关闭窗口,则pipe.send()开始阻止(我使用 CPython 分析器发现了这一点。)谁能告诉我原因,如果可能,如何解决这个问题问题?

产生问题:在脚本更新时关闭弹出的窗口。也就是说,在将一些数字打印到控制台时关闭窗口。

我的系统:macOS Sierra 10.12.5

import multiprocessing as mp
import threading
import random
import time
try:
    import tkinter as tk  # Python3
except ImportError:
    import Tkinter as tk  # Python2

class VisualizedBoard:
    def __init__(self,input_string,pipe):
        '''input_string: a string has a length of at least 81 that represent the board from top-left to bottom right.
        empty cell is 0'''

        self.update_scheduled=False
        self.pipe=pipe

        # create board …
Run Code Online (Sandbox Code Playgroud)

python tkinter multiprocessing python-3.6

2
推荐指数
1
解决办法
3932
查看次数

标签 统计

multiprocessing ×1

python ×1

python-3.6 ×1

tkinter ×1