Good evening. I am working on a program that uses multiprocessing, tkinter and Selenium. I'm trying to pass my Selenium instance to a new process but it's giving me this giant error:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1892, in __call__
return self.func(*args)
File "c:\Users\user\Desktop\coding\PokeClicker Bot\Version 3 (Gui) (WIP)\version3.py", line 37, in <lambda>
item = tk.Button(root, text='Run', relief='raised', command=lambda:toggle(item))
File "c:\Users\user\Desktop\coding\PokeClicker Bot\Version 3 (Gui) (WIP)\version3.py", line 54, in toggle
startRun()
File "c:\Users\user\Desktop\coding\PokeClicker Bot\Version 3 (Gui) (WIP)\version3.py", line 62, in startRun
p.start()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\multiprocessing\context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\multiprocessing\context.py", line 327, in _Popen
return Popen(process_obj)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
reduction.dump(process_obj, to_child)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
TypeError: cannot pickle '_io.TextIOWrapper' object
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 126, in _main
self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
Here's the code, trimmed down for readability:
def init():
global ffD
ffD = WD.Firefox(os.getcwd(), options=options)
ffD.get('https://www.pokeclicker.com/')
root.mainloop()
def runThroughDungeon(driver): #Currently just driver.close() to test.
driver.close()
def startRun(): #Called from toggling tkinter button.
global p
p = mp.Process(target = runThroughDungeon, args=(ffD,))
p.start()
def stopRun():
p.kill()
if __name__ == '__main__':
init()
I'm thinking this is an error due to Selenium having arguments that aren't transferred during the startRun()
process? I'm not really sure, though.