Skip to content

Commit

Permalink
Explicitly prevent using multiprocess on windows.
Browse files Browse the repository at this point in the history
Add note to docs explaining why windows+processes is unsupported.
  • Loading branch information
coleifer committed Jun 5, 2023
1 parent 86e5786 commit c544807
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/consumer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ different mechanisms to achieve this concurrency.

When in doubt, the default setting (``thread``) is a safe choice.

.. warning::
Multiprocess support is not available for Windows. The only process start
method available on Windows is "spawn", which has the downside of requiring
the Huey state to be pickled. Huey uses (and creates) many objects which
cannot be pickled. More information here: `multiprocessing documentation <https://docs.python.org/3/library/multiprocessing.html#the-spawn-and-forkserver-start-methods>`_.

Using gevent
^^^^^^^^^^^^

Expand Down
5 changes: 5 additions & 0 deletions huey/bin/huey_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import sys

from huey.constants import WORKER_PROCESS
from huey.consumer import Consumer
from huey.consumer_options import ConsumerConfig
from huey.consumer_options import OptionParserHandler
Expand Down Expand Up @@ -41,6 +42,10 @@ def consumer_main():
config = ConsumerConfig(**options)
config.validate()

if sys.platform == 'win32' and config.worker_type == WORKER_PROCESS:
err('Error: huey cannot be run in "process"-mode on Windows.')
sys.exit(1)

huey_instance = load_huey(args[0])

# Set up logging for the "huey" namespace.
Expand Down

0 comments on commit c544807

Please sign in to comment.