Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: cannot pickle
#1
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
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()
Reply


Messages In This Thread
TypeError: cannot pickle - by n00sferatu - Dec-14-2021, 12:29 AM
TypeError: cannot pickle - by yakkaligiri - Dec-14-2021, 03:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: cannot pickle ‘_asyncio.Future’ object Abdul_Rafey 1 533 Mar-07-2024, 03:40 PM
Last Post: deanhystad
  pickle problem DPaul 13 5,082 Sep-27-2022, 05:25 PM
Last Post: DPaul
  Multiprocessing Can't pickle local object law 1 16,324 Aug-30-2021, 02:49 PM
Last Post: law
  Save/Loading using pickle Scordomaniac 4 3,114 Nov-24-2020, 06:11 PM
Last Post: Scordomaniac
  computing entropy using pickle files baran01 2 2,492 Dec-30-2019, 09:45 PM
Last Post: micseydel
  Tkinter don't get ver from file via pickle storzo 2 2,619 Jul-31-2019, 03:50 PM
Last Post: storzo
  pickle docs say bytes in one place, strings in another Skaperen 2 2,200 Jul-29-2019, 05:13 PM
Last Post: Skaperen
  pickle error SheeppOSU 4 11,069 Apr-20-2019, 04:50 PM
Last Post: SheeppOSU
  Using pickle.dump Friend 1 2,998 Feb-15-2019, 04:39 PM
Last Post: metulburr
  I'm having trouble with an OOP version of Pickle functionality CodeWolf 2 2,429 Dec-19-2018, 05:41 PM
Last Post: CodeWolf

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020