'PicklingError attribute lookup do_something on __main__ failed

How to fix the below PicklingError? I have the same code as belowed youtube link: https://youtu.be/fKl2JW_qrso?t=1064 However, I have come up this error while running.

import concurrent.futures
import time

############## multiprocessing ##############
start = time.time()


def do_something(seconds):
    print(f'sleeping {seconds} second(s)...')
    time.sleep(seconds)
    return 'Done Sleeping...'


with concurrent.futures.ProcessPoolExecutor() as executor:
    f1 = executor.submit(do_something, 1)
    print(f1.result())


finish = time.time()

print(f'Finished in {round(finish - start, 2)} seconds')
runfile('/Trading/test2.py', wdir='/Trading')
PyDev console: using IPython 7.31.0
Python 3.8.12 (default, Jan  5 2022, 12:00:26) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
concurrent.futures.process._RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/multiprocessing/queues.py", line 239, in _feed
    obj = _ForkingPickler.dumps(obj)
  File "/usr/local/lib/python3.8/multiprocessing/reduction.py", line 51, in dumps
    cls(buf, protocol).dump(obj)
_pickle.PicklingError: Can't pickle <function do_something at 0x7f884a1f5160>: attribute lookup do_something on __main__ failed


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source