Python中的多处理......它是如何工作的?

时间:2016-11-24 20:31:40

标签: python debugging multiprocessing bots

这是我写的脚本的结尾。

while 1:
    if __name__ == '__main__':
        if afkbot_activate == 1:
            print("Thread 1")
            afk = Process(target=afkbot, args=(server, 1200000, 52797,))
            afk.start()
            afk.join()

        if adbot_activate == 1:
            print("Thread 2")
            adb = Process(target=adbot, args=(server, 240, 1, msg_1, msg_2, msg_3, msg_4,))
            adb.start()
            adb.join()

        if votebot_activate == 1:
            print("Thread 3")
            voteb = Process(target=votebot, args=(server, 30,))
            voteb.start()
            voteb.join()

这两个功能确实存在, 但不知何故,这会返回错误

        Traceback (most recent call last):
          File "ts3bot_ultimate.py", line 231, in <module>
            afk.start()
          File "C:\Python33\lib\multiprocessing\process.py", line 111, in start
            self._popen = Popen(self)
          File "C:\Python33\lib\multiprocessing\forking.py", line 241, in __init__
            dump(process_obj, to_child, HIGHEST_PROTOCOL)
          File "C:\Python33\lib\multiprocessing\forking.py", line 160, in dump
            ForkingPickler(file, protocol).dump(obj)
          File "C:\Python33\lib\socket.py", line 116, in __getstate__
            raise TypeError("Cannot serialize socket object")
        TypeError: Cannot serialize socket object

它是如何工作的? 这不起作用......我不明白为什么。我查找了Multiprocessing模块文档,甚至(sortof)复制并修改它。 请保持清晰简单,这是我第一次使用Multiprocessing模块,但我找不到任何可以帮助我解决此问题的好文章或文档。

0 个答案:

没有答案