Skip to content

Commit

Permalink
created a custom class that allows subprocesses to spawn other subpro…
Browse files Browse the repository at this point in the history
…cesses
  • Loading branch information
benne238 committed Jul 12, 2021
1 parent 55cb9ad commit 81e28e5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/webqueue2api/parser/queue.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import multiprocessing
import multiprocessing.pool
import os, re
from pathlib import Path
from .item import Item
Expand Down Expand Up @@ -198,6 +199,20 @@ def load_queues(*queues, headers_only: bool = True) -> list:
Returns:
list: A list of all the queues that were given as arguments, or all of the queues if no queues were specified
"""
# custom class creation based on stackoverflow answer
class NoDaemonProcess(multiprocessing.Process):
# make 'daemon' attribute always return False
def _get_daemon(self):
return False
def _set_daemon(self, value):
pass
daemon = property(_get_daemon, _set_daemon)

# We sub-class multiprocessing.pool.Pool instead of multiprocessing.Pool
# because the latter is only a wrapper function, not a proper class.
class MyPool(multiprocessing.pool.Pool):
Process = NoDaemonProcess

queues = []

for queue in get_valid_queues():
Expand Down

0 comments on commit 81e28e5

Please sign in to comment.