xbrlus / xule

An open-source XBRL processor for business rules, rendering and custom data reporting. See https://xbrl.us/xule for documentation and https://xbrl.us/xule-editor for a VS Code syntax highlighter.
Apache License 2.0
25 stars 10 forks source link

Ability to completely disable any use of multiprocessing.Queue in Xule? #34

Open jonathanflittle opened 4 weeks ago

jonathanflittle commented 4 weeks ago

I'm trying to run Arelle and the Xule plugin in an AWS Lambda function. Part of that environment's limitation is that it does not support /dev/shm, which is required for Python's multiprocessing.Queue to function. For the Xule plugin in Arelle, this ends up being a FileNotFoundError when the XuleGlobalContext attempts to create the rules_queue.

There is already a check in the XuleMessageQueue that prevents the use of multiprocessing.Queue in that class without the --xule-multi command line argument. I'm wondering if the rules_queue of the XuleGlobalContext could also check the --xule-multi argument before trying to use the multiprocessing.Queue, and fall back to using queue.Queue if it is not set? I've done some testing on using Queue instead of M_Queue for the rules_queue and it works for my purposes so far, but I'm unsure of what other side effects it has based on the different ways M_Queue vs. Queue provide objects to the consumer (serialized copies vs. direct references.)

Here's the error when trying to use the M_Queue as the internal Python code attempts to create a SemLock. (Unsupported on AWS Lambda.)

Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/cxFreeze/initscripts/__startup_\.py", line 140, in run File "/usr/local/lib/python3.12/site-packages/cxFreeze/initscripts/console.py", line 25, in run File "arelleCmdLine.py", line 46, in File "/build/arelle/CntlrCmdLine.py", line 61, in main File "/build/arelle/CntlrCmdLine.py", line 73, in parseAndRun File "/build/arelle/CntlrCmdLine.py", line 554, in configAndRunCntlr File "/build/arelle/CntlrCmdLine.py", line 1088, in run File "/usr/local/arelle/plugin/xodel/__init_\.py", line 111, in cmdLineXbrlLoaded process_xodel(cntlr, options, modelXbrl) File "/usr/local/arelle/plugin/xodel/xodel.py", line 175, in process_xodel log_capture = run_xule(cntlr, options, modelXbrl) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/arelle/plugin/xodel/xodel.py", line 219, in run_xule call_xule_method(cntlr, modelXbrl, options.xule_rule_set, runoptions) File "/usr/local/arelle/plugin/xule/__init_\.py", line 970, in callXuleProcessor used_taxonomies = process_xule(rule_set, ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/arelle/plugin/xule/XuleProcessor.py", line 75, in process_xule global_context = XuleGlobalContext(rule_set, modelxbrl, cntlr, options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/arelle/plugin/xule/XuleContext.py", line 234, in __init_\ self.rules_queue = MQueue()
^^^^^^^^^ File "/usr/local/lib/python3.12/multiprocessing/context.py", line 103, in Queue File "/usr/local/lib/python3.12/multiprocessing/queues.py", line 43, in __init__ File "/usr/local/lib/python3.12/multiprocessing/context.py", line 68, in Lock File "/usr/local/lib/python3.12/multiprocessing/synchronize.py", line 169, in __init__ File "/usr/local/lib/python3.12/multiprocessing/synchronize.py", line 57, in __init_\
FileNotFoundError: [Errno 2] No such file or directory Activation of plug-in Xince and Xodel successful, version 1.0. - xodel Xule version: 3.0.30024 -