question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

doit auto crashes with python 3.8 on MacOS

See original GitHub issue

Describe the bug

Considering the following dodo.py file :

/private/tmp$ cat dodo.py 
def task_hello():
    """hello"""

    def python_hello(targets):
        with open(targets[0], "a") as output:
            output.write("Python says Hello World!!!\n")

    return {
        'actions': [python_hello],
        'targets': ["hello.txt"],
        }

doit auto works with python 3.7 :

/private/tmp$ doit --version
0.33.1
lib @ /private/tmp/.env/lib/python3.7/site-packages/doit
/private/tmp$ doit auto
.  hello
^CProcess Process-1:
Traceback (most recent call last):
  File "/usr/local/opt/python@3.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/usr/local/opt/python@3.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/private/tmp/.env/lib/python3.7/site-packages/doit/cmd_auto.py", line 131, in run_watch
    file_watcher.loop()
  File "/private/tmp/.env/lib/python3.7/site-packages/doit/filewatch.py", line 100, in loop
    self._loop_darwin()
  File "/private/tmp/.env/lib/python3.7/site-packages/doit/filewatch.py", line 72, in _loop_darwin
    observer.run()
  File "/private/tmp/.env/lib/python3.7/site-packages/fsevents.py", line 116, in run
    self.event.wait()
  File "/usr/local/opt/python@3.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 552, in wait
    signaled = self._cond.wait(timeout)
  File "/usr/local/opt/python@3.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 296, in wait
    waiter.acquire()
KeyboardInterrupt

but crashes with python 3.8 :

/private/tmp$ doit --version
0.33.1
lib @ /private/tmp/.env-3.8/lib/python3.8/site-packages/doit
/private/tmp$ doit auto
Traceback (most recent call last):
  File "/private/tmp/.env-3.8/lib/python3.8/site-packages/doit/doit_cmd.py", line 190, in run
    return command.parse_execute(args)
  File "/private/tmp/.env-3.8/lib/python3.8/site-packages/doit/cmd_base.py", line 150, in parse_execute
    return self.execute(params, args)
  File "/private/tmp/.env-3.8/lib/python3.8/site-packages/doit/cmd_auto.py", line 139, in execute
    proc.start()
  File "/Users/boileau/opt/anaconda3/lib/python3.8/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/Users/boileau/opt/anaconda3/lib/python3.8/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/Users/boileau/opt/anaconda3/lib/python3.8/multiprocessing/context.py", line 283, in _Popen
    return Popen(process_obj)
  File "/Users/boileau/opt/anaconda3/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Users/boileau/opt/anaconda3/lib/python3.8/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/Users/boileau/opt/anaconda3/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 47, in _launch
    reduction.dump(process_obj, fp)
  File "/Users/boileau/opt/anaconda3/lib/python3.8/multiprocessing/reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
TypeError: cannot pickle '_io.TextIOWrapper' object

Environment

  1. OS: MacOS 10.15.6
  2. python version: Python 3.8.3
  3. doit version: 0.33.1

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
Kwpolskacommented, Sep 4, 2020

Yes, but it can be fixed by manually setting it back to fork with multiprocess.set_start_method('spawn') before spawning a Process. I tested with the above snipper and auto, and it worked in spawn mode with multiprocess.

0reactions
schettino72commented, Apr 10, 2022

@bollwyvl moving discussion to #404

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - doit auto crashes with python 3.8 on MacOS -
Describe the bug. Considering the following dodo.py file : /private/tmp$ cat dodo.py def task_hello(): """hello""" def python_hello(targets): with ...
Read more >
Mac OS Monterey Python Version? | Apple Developer Forums
Could someone tell me the default version of Python, installed with Mac OS Monterey? The one symlinked from /usr/bin/python to /System/Library/Frameworks.
Read more >
Issue 33725: Python crashes on macOS after fork with no exec
msg318352 ‑ (view) Author: Kapil Thangavelu (kapilt) Date: 2018‑06‑01 00:53 msg318361 ‑ (view) Author: Ronald Oussoren (ronaldoussoren) * Date: 2018‑06‑01 05:51 msg318396 ‑ (view) Author:...
Read more >
Install Python 3.8 on macOS - 3 of 9 - YouTube
Install Python 3.8 on macOS - 3 of 9 - Install & Activate a Virtual Environment with PipenvPython on macOS Install GUIDE: ...
Read more >
Updating Python on Mac - Stack Overflow
The default Python on OS X shouldn't be messed with as it's used by the OS itself. If your default is 2.6.1 then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found