• Getting a Process.start() error pickle.PicklingError: Can't pickle

    From marc nicole@3:633/280.2 to All on Tue Sep 3 00:00:15 2024
    Subject: Getting a Process.start() error pickle.PicklingError: Can't pickle
    <type 'module'>: it's not found as __builtin__.module with Python 2.7

    Hello,

    I am using Python 2.7 on Windows 10 and I want to launch a process independently of the rest of the code so that the execution continues while
    the started process proceeds. I am using Process().start() from Python 2.7
    as follows:

    from multiprocessing import Process
    def do_something(text):
    print(text)
    if __name__ == "__main__":
    q = Process(target=do_something,args=("somecmd") )
    q.start()
    # following code should execute right after the q.start() call (not
    until it returns)
    .....


    But getting the error at the call of Process().start():
    pickle.PicklingError: Can't pickle <type 'module'>: it's not found as __builtin__.module

    anybody could provide an alternative to call the function do_something() in
    a separate thread ?

    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)
  • From Stefan Ram@3:633/280.2 to All on Tue Sep 3 06:29:36 2024
    marc nicole <mk1853387@gmail.com> wrote or quoted:
    But getting the error at the call of Process().start():
    pickle.PicklingError: Can't pickle <type 'module'>: it's not found as >__builtin__.module

    I'm not exactly dialed in on Python 2, but threading might be
    less of a headache when it comes to pickling and could still
    check the box for parallelism.



    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: Stefan Ram (3:633/280.2@fidonet)