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
#2
import turtle
paper = turtle.Screen()
pen = turtle.Turtle()


Traceback (most recent call last):
  File "C:/Users/GIRIKALPANA/Desktop/phyton/3.py", line 1, in <module>
    import turtle
Larz60+ write Dec-15-2021, 02:10 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: cannot pickle ‘_asyncio.Future’ object Abdul_Rafey 1 413 Mar-07-2024, 03:40 PM
Last Post: deanhystad
  pickle problem DPaul 13 4,838 Sep-27-2022, 05:25 PM
Last Post: DPaul
  Multiprocessing Can't pickle local object law 1 16,060 Aug-30-2021, 02:49 PM
Last Post: law
  Save/Loading using pickle Scordomaniac 4 3,056 Nov-24-2020, 06:11 PM
Last Post: Scordomaniac
  computing entropy using pickle files baran01 2 2,445 Dec-30-2019, 09:45 PM
Last Post: micseydel
  Tkinter don't get ver from file via pickle storzo 2 2,577 Jul-31-2019, 03:50 PM
Last Post: storzo
  pickle docs say bytes in one place, strings in another Skaperen 2 2,160 Jul-29-2019, 05:13 PM
Last Post: Skaperen
  pickle error SheeppOSU 4 10,994 Apr-20-2019, 04:50 PM
Last Post: SheeppOSU
  Using pickle.dump Friend 1 2,956 Feb-15-2019, 04:39 PM
Last Post: metulburr
  I'm having trouble with an OOP version of Pickle functionality CodeWolf 2 2,376 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