Dec-14-2021, 12:29 AM
(This post was last modified: Dec-14-2021, 09:43 AM by Larz60+.
Edit Reason: fixed error tags
)
Hey guys,
I only a junior in python, but I am trying to start 2 process that listen udp/tcp port. Basically I want to use multiprocessing for "tcp_process" and "udp_process".
I've found multiple stackoverflows on this, but I have no Idea how to adjust my code to make this run succesfully. I understand that my arguments are not pickleable. How do I make it pickable on Windows?
i get below full trace back.
I've found multiple stackverflows, but I have no idea how to adjust the code to run succesfully.
Full trace back
I only a junior in python, but I am trying to start 2 process that listen udp/tcp port. Basically I want to use multiprocessing for "tcp_process" and "udp_process".
I've found multiple stackoverflows on this, but I have no Idea how to adjust my code to make this run succesfully. I understand that my arguments are not pickleable. How do I make it pickable on Windows?
i get below full trace back.
I've found multiple stackverflows, but I have no idea how to adjust the code to run succesfully.
Full trace back
Error:Traceback (most recent call last):
File "C:\Users\p.py", line 94, in <module>
main()
File "C:\Users\p.py", line 87, in main
tcp_process.start()
File "C:\Python\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Python\lib\multiprocessing\context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Python\lib\multiprocessing\context.py", line 327, in _Popen
return Popen(process_obj)
File "C:\Python\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
reduction.dump(process_obj, to_child)
File "C:\Python\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
TypeError: cannot pickle '_thread.lock' object
Snippet def main() -> None: ThreadingTCPServer.allow_reuse_address = True ThreadingUDPServer.allow_reuse_address = True tcp_proxy = ThreadingTCPServer((PROXY_ADDR, PROXY_PORT), DNSoverTCP) udp_proxy = ThreadingUDPServer((PROXY_ADDR, PROXY_PORT), DNSoverUDP) tcp_process = multiprocessing.Process(target=tcp_proxy.serve_forever) udp_process = multiprocessing.Process(target=udp_proxy.serve_forever) tcp_process.start() logging.info('listening on port %s', PROXY_PORT) udp_process.start() logging.info('udp on port %s', PROXY_PORT) if __name__ == '__main__': main()